#274 Aggregating Employees by City

Companies:
Sberbank
Themes:
SQLAggregationPractice

The following table is given:

DROP TABLE IF EXISTS employee;

CREATE TABLE IF NOT EXISTS employee (
    name VARCHAR(30) PRIMARY KEY,
    city VARCHAR(50)
);

INSERT INTO employee VALUES
    ('Ivanov', 'Moscow'),
    ('Petrov', 'Moscow'),
    ('Sidorov', 'Voronezh');

It is necessary to:

  • Display a unique list of cities.
  • Display the number of employees in each city.
  • Display only cities where the number of employees is greater than 1.

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in