April 7, 2011 at 1:11 pm
I have a table with the fields 'User','Send','Receive' & 'Message'. The user Edita might be in the table 100 times and the user Editb might be in the table 250 times. My goal is to pull one distinct row for each unique user so I can cycle through my results and find out how many unique users are inside the table. Is there a query that can be built to accomplish such a task?
April 7, 2011 at 1:15 pm
two typical methods can be used
select distinct user from yourtable
--or
select user from yourtable group by user
Lowell
April 7, 2011 at 1:25 pm
Thank you. I love forums because I always get great responses like this one.
April 7, 2011 at 8:59 pm
Actually if all you want is the count of unique users, don't return them and spin through them that just wastes network bandwidth, etc.. Use a COUNT query instead:
SELECT
COUNT(DISTINCT User) AS User_Count
FROM dbo.YourTable;
That way you get just the one number you need.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply