-
Notifications
You must be signed in to change notification settings - Fork 203
Expand file tree
/
Copy pathlab2-sql.sql
More file actions
71 lines (44 loc) · 1.44 KB
/
lab2-sql.sql
File metadata and controls
71 lines (44 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
-- Select all the actors with the first name ‘Scarlett
select *
from sakila.actor
where first_name = 'Scarlett';
-- Select all the actors with the last name ‘Johansson’.
select *
from sakila.actor
where capital_surname = 'Johansson';
-- How many films (movies) are available for rent? 4581
select count(film_id)
from sakila.inventory;
-- How many films have been rented? 16044
select count(rental_id)
from sakila.rental;
-- What is the shortest and longest rental period? 7 max and 3 min
select max(rental_duration)
from sakila.film;
select min(rental_duration)
from sakila.film;
-- What are the shortest and longest movie duration? Name the values max_duration and min_duration.
select *
from sakila.film;
select min(length) as min_duration
from sakila.film;
select max(length) as max_duration
from sakila.film;
-- What's the average movie duration? 115.2720
select avg(length)
from sakila.film;
-- What's the average movie duration expressed in format (hours, minutes)? 01:55 H
select
TIME_FORMAT(SEC_TO_TIME(AVG(LENGTH * 60)), '%H:%i') as
average_duration_hoursandminutes
from sakila.film;
-- How many movies longer than 3 hours? 39
select count(*)
from sakila.film
where length > 180;
-- Get the name and email formatted. Example: Mary SMITH - mary.smith@sakilacustomer.org.
-- What's the length of the longest film title? 27
select *
from sakila.film;
select MAX(length(title)) as longest_film_length
from sakila.film;