0

Is there a way to get the count for each distinct value for a certain field?

for name in (SELECT DISTINCT name FROM table)
  SELECT COUNT name FROM table

without using a cursor that is

Drew
  • 2,583
  • 5
  • 36
  • 54

1 Answers1

5

You may use COUNT() -- an aggregate function.

SELECT Name, COUNT(*) totalCount
FROM tableName
GROUP BY Name
John Woo
  • 258,903
  • 69
  • 498
  • 492