close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

MySQL language help needed

Thread began 4/15/2009 12:31 pm by mustang_sally_85344510 | Last modified 4/17/2009 10:29 am by Ray Borduin | 1926 views | 5 replies |

mustang_sally_85344510

MySQL language help needed

I'm working in DW3, and using PHP format for my database driven site.
The site draws on the database for points that have been inserted into the database.

What I am trying to accomplish is total the points by player_Id, and post their lastname, firstname, and rank it according to sum(points) in descending order.

My queery below, brings up the information I want...
But I just can't seem to come up with the right syntex to use to count() the records.

What happens is it ends up counting how many records it took to make the sum(points).

Here is the code I use to total the points. everything but the count is added.

SELECT sum(points) as 'points', lastname, firstname, player_id
FROM points
WHERE month = '02'
GROUP BY player_id
ORDER BY sum(points) desc LIMIT 0, 200

here is a link to the working page.
marchpoint.php

I just need some help getting the darn thing to "count" records so I can use it for the "rank". For example next to the player_id ...I need to add a "rank" column, which would go from 1 to 200.

Any help would be deeply appreciated!

Sign in to reply to this post

Ray BorduinWebAssist

SELECT sum(points) as points, count(player_id) AS idCount, lastname, firstname, player_id
FROM points
WHERE month = '02'
GROUP BY player_id
ORDER BY sum(points) desc LIMIT 0, 200

Sign in to reply to this post

mustang_sally_85344510

Doesn't work

Just tried it...
It doesn't work...
It ends up counting how many times the player_id was used to sum the points...:(

Sign in to reply to this post

Ray BorduinWebAssist

I thought that is what you wanted. What table do you want to count from?

You can use count( DISTINCT ColumnName) and do the count based on any other field.

Sign in to reply to this post

mustang_sally_85344510

Didn't work either

Tried that...
That didn't work either.

Because I need to use "group by player_id" to sum the points....

No matter what I seem to try...
It ends up counting how many entries were used to sum the points.

When I use "Distinct" it shows "1", as each player does have a unique "distinct ID".

Do I need to create a new blank field in the table?

I do appreciate all the help you are trying to give me so far! :)

Sign in to reply to this post

Ray BorduinWebAssist

Use a nested SELECT statement so you can have a separate where and group by clause for your count.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...