-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathben-LabSQL Queries 3.sql
More file actions
33 lines (28 loc) · 1.22 KB
/
ben-LabSQL Queries 3.sql
File metadata and controls
33 lines (28 loc) · 1.22 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
-- How many distinct (different) actors' last names are there?
select * from sakila.actor
select last_name from sakila.actor
-- In how many different languages where the films originally produced? (Use the column language_id from the film table)
select count(language_id) AS "Fimls_Orginal" from sakila.language;
-- How many movies were released with "PG-13" rating?
SELECT COUNT(rating) AS customers_in_UK -- Rating = Columna AS Es como quieres que se llame ese resultado
FROM sakila.film -- Sakila.film es la base de datos
WHERE rating = 'PG-13'; -- WHERE rating = 'PG-13' eso quiere decir que dentro de la columna rating busca 'PG-13'
--
-- Get 10 the longest movies from 2006.
SELECT MAX(length),release_year
FROM sakila.film
WHERE release_year = 2006
LIMIT 10;
-- CHAT GDP HELP Why I need to add the order by?
SELECT length, release_year
FROM sakila.film
WHERE release_year = 2006
ORDER BY length DESC
LIMIT 10;
--
-- How many days has been the company operating (check DATEDIFF() function)?
SELECT DATEDIFF('2006-02-14','2005-05-25') AS days_difference
-- Show rental info with additional columns month and weekday. Get 20.
SELECT MONTHNAME(rental_date) AS month, DAYNAME(rental_date) AS day_of_week
FROM sakila.rental
LIMIT 20;