Saturday 24 October 2015

SQL 'COUNT()' Function

Given a table STATION that holds data for five fields namely ID, CITY, STATE, NORTHERN LATITUDE and WESTERN LONGITUDE.
+-------------+------------+
| Field       |   Type     |
+-------------+------------+
| ID          | INTEGER    |
| CITY        | VARCHAR(21)|
| STATE       | VARCHAR(2) |
| LAT_N       | NUMERIC    |
| LONG_W      | NUMERIC    |
+-------------+------------+

Let NUM be no. of cities and NUMunique be no. of unique cities, then write a query to print the value of NUM - NUMunique


>>select count(city)-count(distinct city) from station;





Thanks.





No comments:

Post a Comment