You are viewing a single comment's thread. Return to all comments →
there are two ways to compute the difference between: 1. total number of CITY entries (including duplicates) 2. number of distinct CITY entries.
Assuming the table is named STATION and the column is CITY First method: 1. SQL to get the difference directly
SELECT COUNT(CITY) - COUNT(DISTINCT CITY) AS city_duplicate_diff FROM STATION;
Second method: 2.If you want to see the two counts separately (total vs distinct) and compute the difference in a single result:
SELECT total_city AS total_city_entries, distinct_city AS distinct_city_entries, total_city - distinct_city AS city_duplicate_diff FROM ( SELECT COUNT(CITY) AS total_city, COUNT(DISTINCT CITY) AS distinct_city FROM STATION ) AS t;
Seems like cookies are disabled on this browser, please enable them to open this website
Weather Observation Station 4
You are viewing a single comment's thread. Return to all comments →
Hello here is the code to solve the problem
there are two ways to compute the difference between: 1. total number of CITY entries (including duplicates) 2. number of distinct CITY entries.
Assuming the table is named STATION and the column is CITY First method: 1. SQL to get the difference directly
Second method: 2.If you want to see the two counts separately (total vs distinct) and compute the difference in a single result: