G
Guest
Hello,
I need to count the number of occurrences for many different entries in a
table. Basically, I have a "category" column (socnm) that contains many
occurrences of several different categories. What I'm hoping to do is select
the DISTINCT rows from the column and then use them to get the count for each
category in the table. I tried:
SELECT count(*) AS [COUNT]
FROM Test
WHERE Test.socnm IN (SELECT DISTINCT [Test].[socnm] FROM Test);
But it just ended up giving me a count equal to the total number of rows. I
want to do a count for distinct socnm(1) and then save/output it then loop
through socnm(N) each time saving/outputting the count for that category. I'm
thinking of this from a linear programming POV.......Can anyone straighten me
out?
Thanks very, very much in advance.
Brett
I need to count the number of occurrences for many different entries in a
table. Basically, I have a "category" column (socnm) that contains many
occurrences of several different categories. What I'm hoping to do is select
the DISTINCT rows from the column and then use them to get the count for each
category in the table. I tried:
SELECT count(*) AS [COUNT]
FROM Test
WHERE Test.socnm IN (SELECT DISTINCT [Test].[socnm] FROM Test);
But it just ended up giving me a count equal to the total number of rows. I
want to do a count for distinct socnm(1) and then save/output it then loop
through socnm(N) each time saving/outputting the count for that category. I'm
thinking of this from a linear programming POV.......Can anyone straighten me
out?
Thanks very, very much in advance.
Brett