views:

19

answers:

1

Hi

I have this table:

id name
1  A
1  B
2  C
2  D
2  E
3  F

and I need to get this:

id qty
1  2
2  2
3  1
+4  A: 
SELECT id, COUNT(name) AS qty
FROM tablename
GROUP BY id
ORDER BY id

But that would return

id qty
1 2
2 *3*
3 1

Not sure if that is a typo.

Chris Diver