Harness the power of practice to master SQL. Our interactive exercises are designed to solidify your understanding, from foundational concepts to advanced techniques. Whether you're a SQL novice or a seasoned pro, you’ll find challenges tailored to your skill level. Boost your confidence for job interviews and real-world applications through consistent practice.
I am writing to you today because I need your help.
SQLtest.online is a free platform designed to help people of all levels master SQL.
We offer a wide range of interactive tests, problems and training materials to help you improve your SQL skills.
The platform has already helped a lot of people, but we want to make it even better. And this is where you can help us!
How you can help:
Invite your friends and colleagues to join SQLtest.online!
Tell your friends and colleagues about SQLtest.online. Share a link to our site on social networks, by email or in person.
Write an article or blog post about SQLtest.online. Share your experience with the platform.
Together we can make SQLtest.online the best resource for learning SQL!
The more people use the platform, the better it will become. We'll be able to add more content, improve features, and create a better community for SQL enthusiasts.
Find the names of managers and store addresses of the company.
Display the result as a table with the columns: store_id, manager and address.
The manager column should display the last name and the first letter of the name with a dot after it. For example: Silverman B.
Sort the data in ascending order of the store_id field
Write your request in the field below and click the "Check it!" button.
To write the answer, use MySQL syntax. Descriptions of the tables are given in the right panel.
Sakila is a sample database developed by MySQL, specifically designed to teach and demonstrate the capabilities of database management systems (DBMS) based on the relational model.
last_update - When the row was created or most recently updated.
actor_id
first_name
last_name
last_update
1
John
Doe
2023-01-01 12:00:00
Indexes:
PRIMARY KEY, btree (actor_id)
Table address
Table columns:
address_id - Unique identifier for each address.
address - Street address.
address2 - Additional address.
district - District or region.
city_id - Foreign key referencing the city table.
postal_code - Postal code.
phone - Phone number.
last_update - When the row was created or most recently updated.
address_id
address
address2
district
city_id
postal_code
phone
last_update
1
123 Main St
[null]
Downtown
1
12345
+1234567890
2023-01-01 12:00:00
Indexes:
PRIMARY KEY, btree (address_id)
Table category
Table columns:
category_id - Unique identifier for each category.
name - Name of the category.
last_update - When the row was created or most recently updated.
category_id
name
last_update
1
Action
2023-01-01 12:00:00
Indexes:
PRIMARY KEY, btree (category_id)
Table city
Table columns:
city_id - Unique identifier for each city.
city - City name.
country_id - Foreign key referencing the country table.
last_update - When the row was created or most recently updated.
city_id
city
country_id
last_update
1
Metropolis
1
2023-01-01 12:00:00
Indexes:
PRIMARY KEY, btree (city_id)
Table country
Table columns:
country_id - Unique identifier for each country.
country - Country name.
last_update - When the row was created or most recently updated.
country_id
country
last_update
1
United States
2023-01-01 12:00:00
Indexes:
PRIMARY KEY, btree (country_id)
Table customer
Table columns:
customer_id - Unique identifier for each customer.
store_id - Foreign key referencing the store table.
first_name - First name of the customer.
last_name - Last name of the customer.
email - Email address of the customer.
address_id - Foreign key referencing the address table.
active - Indicates whether the customer is active.
create_date - Timestamp indicating when the customer was added to the database.
last_update - When the row was created or most recently updated.
customer_id
store_id
first_name
last_name
email
address_id
active
create_date
last_update
1
1
John
Doe
john.doe@example.com
1
true
2023-01-01 12:00:00
2023-01-01 12:00:00
Indexes:
PRIMARY KEY, btree (customer_id)
Table film
Table columns:
film_id - Unique identifier for each film.
title - The title of the film.
description - A short description or plot summary of the film.
release_year - The year in which the movie was released.
language_id - Foreign key referencing the language table; identifies the language of the film.
original_language_id - A foreign key pointing at the language table; identifies the original language of the film. Used when a film has been dubbed into a new language.
rental_duration - The length of the rental period, in days.
rental_rate - The cost to rent the film for the period specified in the rental_duration column.
length - Duration of the film, in minutes.
replacement_cost - The amount charged to the customer if the film is not returned or is returned in a damaged state.
rating - The rating assigned to the film. Can be one of: G, PG, PG-13, R, or NC-17.
special_features - Lists which common special features are included on the DVD. Can be zero or more of: Trailers, Commentaries, Deleted Scenes, Behind the Scenes.
last_update - When the row was created or most recently updated.
film_id
title
description
release_year
language_id
original_language_id
rental_duration
rental_rate
length
replacement_cost
rating
special_features
last_update
1
Film Title
A brief description of the film.
2000
1
2
5
4.99
120
19.99
PG-13
Trailers, Commentaries
2023-01-01 12:00:00
Indexes:
PRIMARY KEY, btree (film_id)
Table film_actor
Table columns:
actor_id - Unique identifier for actor.
film_id - Unique identifier for film.
last_update - When the row was created or most recently updated.
actor_id
film_id
last_update
1
1
2023-01-01 12:00:00
Indexes:
PRIMARY KEY, btree (actor_id, film_id)
Table film_category
Table columns:
film_id - Unique identifier for each film.
category_id - Unique identifier for each category.
last_update - When the row was created or most recently updated.
film_id
category_id
last_update
1
1
2023-01-01 12:00:00
Indexes:
PRIMARY KEY, btree (film_id, category_id)
Table inventory
Table columns:
inventory_id - Unique identifier for each inventory item.
film_id - Unique identifier for each film in the inventory.
store_id - Unique identifier for the store where the inventory item is located.
last_update - When the row was created or most recently updated.
inventory_id
film_id
store_id
last_update
1
23
2
2023-01-01 12:00:00
Indexes:
PRIMARY KEY, btree (inventory_id)
Table language
Table columns:
language_id - Unique identifier for each language.
name - Language name.
last_update - When the row was created or most recently updated.
language_id
name
last_update
1
English
2023-01-01 12:00:00
Indexes:
PRIMARY KEY, btree (language_id)
Table payment
Table columns:
payment_id - Unique identifier for each payment.
customer_id - Foreign key referencing the customer table.
staff_id - Foreign key referencing the staff table.
rental_id - Foreign key referencing the rental table.
amount - Payment amount.
payment_date - Date of the payment.
last_update - When the row was created or most recently updated.
payment_id
customer_id
staff_id
rental_id
amount
payment_date
last_update
1
1
1
1
4.99
2023-01-01 12:13:14
2023-01-01 12:14:15
Indexes:
PRIMARY KEY, btree (payment_id)
Table rental
Table columns:
rental_id - Unique identifier for each rental.
rental_date - Date when the rental occurred.
inventory_id - Foreign key referencing the inventory table.
customer_id - Foreign key referencing the customer table.
return_date - Date when the rental was returned.
staff_id - Foreign key referencing the staff table.
last_update - When the row was created or most recently updated.
rental_id
rental_date
inventory_id
customer_id
return_date
staff_id
last_update
1
2023-01-01 16:15:21
1
1
2023-01-10 09:12:36
1
2023-01-01 12:00:00
Indexes:
PRIMARY KEY, btree (rental_id)
Table staff
Table columns:
staff_id - Unique identifier for each staff member.
first_name - First name of the staff member.
last_name - Last name of the staff member.
address_id - Foreign key referencing the address table.
picture - Staff member picture.
email - Email address of the staff member.
store_id - Foreign key referencing the store table.
active - Indicates whether the staff member is active.
username - Username for login.
password - Password for login.
last_update - When the row was created or most recently updated.
staff_id
first_name
last_name
address_id
picture
email
store_id
active
username
password
last_update
1
John
Doe
1
[null]
john.doe@example.com
1
true
johndoe
********
2023-01-01 12:00:00
Indexes:
PRIMARY KEY, btree (staff_id)
Table store
Table columns:
store_id - Unique identifier for each store.
manager_staff_id - Foreign key referencing the staff table for the store manager.
address_id - Foreign key referencing the address table.
last_update - When the row was created or most recently updated.