Sql count | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Sql count

How can i select the differences between occurance of rows in a table and the occurance of a distinct rows in a table. Heres what i have tried.. select count(city) from station-select count(distinct city) from station

7th Aug 2020, 9:25 AM
sid
sid - avatar
5 Answers
+ 2
Select count(field) - count(distinct field) as diff will work on most databases.
7th Aug 2020, 5:16 PM
Sandra Meyer
Sandra Meyer - avatar
+ 3
Ipang Sandra Meyer thank you guyz
8th Aug 2020, 4:23 AM
sid
sid - avatar
+ 2
Ipang no it didnt work
7th Aug 2020, 11:22 AM
sid
sid - avatar
+ 2
Ipang i want to see the number of the records based on their cities (can contain duplicates) - no of records with no duplicate city name
7th Aug 2020, 11:31 AM
sid
sid - avatar
+ 2
Sandra Meyer thank you it works
8th Aug 2020, 4:23 AM
sid
sid - avatar