The following questions will help you to practice writing SQL statements. The qu
ID: 3913588 • Letter: T
Question
The following questions will help you to practice writing SQL statements. The questions are based on the "sakila" database schema on MySQL Workbench.
1. Write the sql statement that will provide you a list of all actors names sorted by last name, then by first name. (Without using the wildcard (*) for the fields.)
2. Write the sql statement that will provide you a list of all films rated R and include the record count. (Without using the wildcard (*) for the fields.)
3. Write the sql statement that will provide you a list of all films that are category “Action” and include the record count. (Without using the wildcard (*) for the fields.)
4. Write the sql statement that will provide you a list of all films that have the string “SIDE” in their name and include the record count. (Without using the wildcard (*) for the fields.)
5. Write the sql statement that will provide you with just the count of films under 90 minutes and include the record count and the film count. (Without using the wildcard (*) for the fields.)
Explanation / Answer
1.
Select first_name,last_name from actor order by last_name,first_name;
2.
Select title,count(film_id) from film group by rating having rating = 'R';
3.
Select title,count(film_id) from film inner join film_category on film.film_id = film_category.film_id inner join category on film_category.category_id = category.category_id group by category_id having category.name = 'Action';
4.
Select title,count(film_id) from film group by title having title like '%SIDE%';
5.
Select title,count(film_id) from film group by length having length < 90;
Do ask if any doubt. Please upvote.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.