Skip to content

Latest commit

 

History

History

Onboarded Cities

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Onboarded Cities

Star Badge View Main Folder View Repositories View My Profile


🛠️ Problem Statement

Table Name : business_city

Column Name Type
business_date date
city_id int

The table contains two columns business_date and city_id. city_id is the ID of the city which has been onboarded for the business. Note that there could be multiple instances of onboarding of a particular city.

Write a SQL query to find the Unique number of cities onboarded for the business for the first time for each year.

Return the result table in the order of business_year.

The query result format is in the following example.

Input

Table Name: business_city

business_year city_id
2020-01-02 3
2020-07-01 7
2021-01-01 3
2021-02-03 19
2022-12-01 3
2022-12-15 3
2022-02-28 12
Output
business_city no_of_onboarded_cities_for_the_first_time
2020 2
2021 1
2022 1