Answer the question
In order to leave comments, you need to log in
Is the SQL query built correctly?
Greetings! Just started learning SQL. Ask for help from experts.
Given 2 tables:
- table gorod with fields: id, city_name, region_id, naselenie;
- region table with fields: id, region_name;
Write a query that allows you to determine the number of cities that is stored in the gorod table for each region, i.e. the result should be in the form: name of the corresponding region / number of cities. Here is my version:
SELECT region.region_name, COUNT(gorod.city_name)
FROM region INNER JOIN gorod
WHERE region.region_id = gorod.region_id
GROUP BY region.region_name;
Tell me, please, does this happen or do you need ON instead of WHERE?
Answer the question
In order to leave comments, you need to log in
SELECT region.region_name, COUNT(gorod.city_name)
FROM region INNER JOIN gorod
ON region.region_id = gorod.region_id
GROUP BY region.region_name;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question