Jump to content

Archived

This topic is now archived and is closed to further replies.

lead2gold

Simple count query - just can't do it

Recommended Posts

Ok, i guess my brain isn't working...
What am i doing wrong?
[code]
SELECT count( gid )
FROM table
WHERE sid =1
GROUP BY gid
[/code]
the above returns 2.

I currently have 2 entries in the entire database (to make testing easy).
What i want to have returned is 1 because both entries have the same gid.

How do i manipulate the above to acomplish this?

Share this post


Link to post
Share on other sites
[code]
SELECT
COUNT(DISTINCT gid) AS num
FROM
tablename
WHERE
sid = 1
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.