Quote:Original post by Wan
I think this should work (untested):In the first column we're selecting all distinct addresses, in the second column we count the number of distinct surnames within a particular address.SELECT DISTINCT address, COUNT(DISTINCT(surname))FROM Table1GROUP BY address
+1 (well, the syntax is COUNT(DISTINCT surname) and the GROUP BY makes the first DISTINCT pointless, but you get the idea).