Reputation: 31
What is the query to choose the number of people living at each address?
(data should be in the form of ‘Address - Number of residents’) table - Contact.CL_Info
FIO Address Phone Age
ФИО1 Адрес1 123 11
ФИО2 Адрес2 123 12
ФИО3 Адрес3 123 13
ФИО4 Адрес4 123 14
ФИО5 Адрес2 123 14
ФИО6 Адрес3 123 13
ФИО7 Адрес5 123 12
ФИО8 Адрес6 123 11
ФИО9 Адрес7 (null) 15
ФИО10 Адрес8 123 21
Upvotes: 0
Views: 84
Reputation: 314
You have to use GROUP BY
Address to get the count for each address.
SELECT Address, COUNT(*) AS AddressCount
FROM Contact.CL_Info
GROUP BY Address
Upvotes: 0
Reputation: 312008
You could issue a count
and group it by the address
:
SELECT address, count(*)
FROM Contact.CL_Info
GROUP BY address
Upvotes: 4