Quiz On Select and Subqueries
Quiz On Select and Subqueries
Write the SELECT statement that will answer the following queries. Write the SELECT statement that will answer the following queries.
1. Display the film title, description, length, rental_duration, and rental_rate arranged 1. Display the film title, description, length, rental_duration, and rental_rate arranged
in alphabetical order of film title. (film) from the most expensive rental_rate. (film)
2. How many customers are there per store? (customer) 2. Display the customer_id and the total amount paid by each customer. (payment)
3. Display the film title, description and length of all movies that are allowed up to 3 3. Display the film title, special_features and length of all movies that has a rental rate
days rental duration only. Display the list of films in descending order of length. of 2.99 dollar only. Display the list of films arranged in alphabetical order of rating.
(film) (film)
4. Display the film title, special_features, rating and length of all PG, R and NC-17 rating 4. Display the film title, description, and length of all G, PG-13 and PG rating movies
movies that includes Trailers in the special features. Order the display from longest that has ‘Boy’ in the description. Order the display from the shortest(length) film
(length) film first. (film) first. (film)
5. Display the actor_id, number of films of all actors whose last name starts with ‘A’, ‘B’ 5. Display the customer_id, total payment made by customers of store_id =1 and
or ‘C’. Arrange the results from the actor with most number of films. (film_actor, whose last name ends with ‘N’. (payment, customer)
actor)
Name:_____________________________________Section:________________Score:_____ Name:_____________________________________Section:________________Score:_____
Write the SELECT statement that will answer the following queries. Write the SELECT statement that will answer the following queries
1. Display the complete name and email of all active customers (i.e. active is 1). 1. Display the complete name and email of all store 1 customers. Arrange the results in
Arrange the results in alphabetical order of customer name. (customer) alphabetical order of customer name (customer)
2. Display the film title, rental_duration, rental_rate and rating of all PG and PG-13 2. Display the film title, rental_duration, rental_rate and rating of all R and NC-17 films
containg deleted scenes and that allows more than 3 days duration of the rental. that has a length of at least 1 hr but not more than 2 hrs. Note that length in the
table contains the number of minutes.
3. How many rentals were processed by each staff member? Display the staff_id and 3. How many rentals were made by customer? Display the customer_id and the total
the total number of rentals processed arranged by staff with the most number of number of rentals made, arranged by customer with the least number of rentals.
rentals. (rentals) (rentals)
4. What is the total collection made per month by each staff? Display the month of the 4. What is the total amount paid by each customer with customer id 1 to 10 for the
payment date, staff_id and the total of amount paid by the customer. Order the third quarter of the year(i.e. July, August, Sept)? Display the customer_id and the
results from highest to lowest total amount or collection. (payment) total of amount paid by the customer. Order the results from lowest to highest
payments made. (payment)
5. Display the last name and first name of the actors of the film JUMANJI BLADE? ( film, 5. Display the title, length, and ratings of the film where ‘STALLONE, NICK’ is one of the
film_actor, actor) actors. (actor, film_actor, film)