I am formulating a MySQL query that tries to aggregate a COUNT. The data looks like this....table is "workers"
NAME DPT
----- ----
CLARK 10
JAMES 10
ALLEN 10
ADAMS 20
WU 20
MARTIN 30
FITZ 30
SCHMIDT 30
MILLER 30
I need to list the table like this with a count in the departments
NAME DPT CNT
----- ---- ---
CLARK 10 3
JAMES 10 3
ALLEN 10 3
ADAMS 20 2
WU 20 2
MARTIN 30 4
FITZ 30 4
SCHMIDT 30 4
MILLER 30 4
I tried this...
SELECT DISTINCT(NAME), DPT, COUNT(DPT) as CNT FROM workers GROUP BY DPT;
with no success. Pretty sure it's something simple but I'm stumped. Any ideas on where I am going wrong? - JW