I have this table/data structure:
ID Area Postcode
------------------------
1 "Area 1" "EN1 1NE"
2 "Area 2" "AB2 3BA"
3 "Area 1" "EN1 1NE"
4 "Area 3" "XY4 5ZA"
5 "Area 4" "MN6 5OP"
Rows 1 and 3 have duplicate Postcodes and Areas. I need a query that outputs counts like this this:
Area Postcode Count
----------------------------
"Area 1" "EN1 1NE" 2
"Area 2" "AB2 3BA" 1
"Area 3" "XY4 5ZA" 1
"Area 4" "MN6 5OP" 1
I’ve searched and played about with DISTINCT and/or COUNT and/or subqueries but getting really lost here! #weak-sql-fu
Thanks!
Ben
You can use count(*) with group by like this: