Jump to content


Photo

Simple count query - just can't do it


  • Please log in to reply
2 replies to this topic

#1 lead2gold

lead2gold
  • Members
  • PipPipPip
  • Advanced Member
  • 164 posts
  • LocationOttawa, On

Posted 19 July 2006 - 05:54 PM

Ok, i guess my brain isn't working...
What am i doing wrong?
SELECT count( gid )
FROM table
WHERE sid =1
GROUP BY gid
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?

#2 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 19 July 2006 - 06:05 PM

SELECT
COUNT(DISTINCT gid) AS num
FROM
tablename
WHERE
sid = 1


#3 lead2gold

lead2gold
  • Members
  • PipPipPip
  • Advanced Member
  • 164 posts
  • LocationOttawa, On

Posted 19 July 2006 - 06:08 PM

I'll give some grace for that!

Thanks a million!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users