-
Notifications
You must be signed in to change notification settings - Fork 203
Expand file tree
/
Copy pathLab_SQL_Queries 2.sql
More file actions
89 lines (62 loc) · 1.93 KB
/
Lab_SQL_Queries 2.sql
File metadata and controls
89 lines (62 loc) · 1.93 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
-- selecting first_name as scarlett in all actor list
select *
from sakila.actor
where first_name = 'Scarlett';
-- selecting last_name as ‘Johansson’ in all actor list
select *
from sakila.actor
where last_name = 'Johansson';
-- check how many film are available for rent
select *
from sakila.film, inventory
;
select count(film_id)
from sakila.inventory ;
-- 4581 film are available to be renteed
-- Now checking how many film have been rented
-- 16044 film have been rented
select count(rental_id)
from sakila.rental;
-- What is the shortest and longest rental period?
-- max rental period is 7 days
-- min rental periodo is 3 days
select min(rental_duration)
from sakila.rental,film;
select max(rental_duration)
from sakila.rental,film;
-- What are the shortest and longest movie duration? Name the values max_duration and min_duration.
-- min_duration = 46 \ max_duration = 185
select min(length) as min_duration
from sakila.rental,film;
select max(length) as max_duration
from sakila.rental,film;
select length
from sakila.rental,film;
-- What's the average movie duration?
-- average duration is 115.2720
select avg(length) as avg_duration
from sakila.rental,film;
-- What's the average movie duration expressed in format (hours, minutes)? format is minutes
-- How many movies longer than 3 hours?
-- 625716 film are more longer than 3 hours
select count('rental_id')
from sakila.rental,film
WHERE length > 180 ;
select *
from sakila.rental,film
WHERE length > 180 ;
-- Get the name and email formatted. Example: Mary SMITH - mary.smith@sakilacustomer.org.
select lower(first_name)
from sakila.customer
select lower(email)
from sakila.customer;
SELECT last_name, lower(first_name),lower(email)
FROM sakila.customer;
-- What's the length of the longest film title?
-- the length of the longest film title is 27 caracter
select *
from film, sakila.rental;
select length(title)
from sakila.film
select max(length(title))
from sakila.film