My Table is as follows
- STUDENT TABLE
- STUDENT NAME - COUNTY
- John - Waterford
- Chris - Waterford
- Anne - Tipperary
- Paul - Cork
- Thomas - Cork
Clearly form the table 3 differrent counties exist, I am looking for a count statement to show that three different counties exist.
Currently I am at
SELECT COUNT(county)
FROM Student;
I have tried Grouping and I can seem to count everything in the table bar the number of counties, any help would be great.
use group by
SELECT county,COUNT(county)
FROM Student group by county;
Use DISTINCT
to count each county only once:
SELECT COUNT( DISTINCT county)
FROM Student;
Use GROUP BY clause in you query
SELECT COUNT(county) FROM Student GROUP BY `county`;
also you can add DISTINCT as "lad2025" suggested.