Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

use movies;

-- Sa se afiseze numele si prenumele tuturor actorilor. Rezultatul sa fie continut intr-o singura coloana 'nume
complet'
SELECT concat(a.act_firstname, a.act_lastname) AS 'Complete Names'
FROM actors a;

-- Afisati numarul total de filme


SELECT COUNT(*) AS 'Total Number of Movies'
FROM movies;

-- Afisati titlul si data aparitiei pentru toate filmele aparute dupa 2012 ordonate alfabetic dupa titlu
SELECT mov_title, mov_publishdate
FROM movies
WHERE mov_publishdate > '2012-01-01'
ORDER BY mov_title ASC;

-- Afisati toate filmele horror aparute dupa 2012 ordonate descrescator dupa data aparitiei ordonate alfabetic
dupa titlu
SELECT m.mov_title,
m.mov_publishdate,
g.gen_title
FROM movies m
JOIN mov_genres mg ON m.mov_id = mg.mov_id
JOIN genres g ON mg.gen_id = g.gen_id
WHERE g.gen_title = 'Horror' AND m.mov_publishdate > '2012-01-01'
ORDER BY m.mov_title DESC;

-- Afisati toate filmele de actiune aparute dupa 2015 ordonate crescator dupa data aparitiei
SELECT m.mov_title,
m.mov_publishdate,
g.gen_title
FROM movies m
JOIN mov_genres mg ON m.mov_id = mg.mov_id
JOIN genres g ON mg.gen_id = g.gen_id
WHERE g.gen_title = 'Action' AND m.mov_publishdate > '2015-01-01'
ORDER BY m.mov_title ASC;

-- Afisati toate filmele de comedie in care a jucat Chris Tucker ordonate descrescator dupa an si alfabetic
dupa titlu.alter
SELECT *
FROM movies m
JOIN movie_cast mc ON m.mov_id = mc.mov_id
JOIN actors a ON mc.act_id = a.act_id
WHERE a.act_lastname = 'Tucker';
-- ORDER BY m.mov_publishdate desc, m.mov_title asc

-- Afisati toate filmele regizate de George Lucas


SELECT d.dir_fname,
d.dir_lname,
m.mov_title
FROM director d
JOIN mov_dir md ON d.dir_id = md.dir_id
JOIN movies m ON md.mov_id = m.mov_id
WHERE d.dir_lname = 'Lucas';

-- Afisati cate filme a regizat Quentin Tarantino


SELECT COUNT(*)
FROM director d
JOIN mov_dir md ON d.dir_id = md.dir_id
JOIN movies m ON md.mov_id = m.mov_id
WHERE d.dir_lname = 'Tarantino';

-- Afisati top 3 regizori de film dupa numarul de filme regizate. Ordonati rezultatul crescator dupa numarul
de filme

-- Afisati numarul de filme din fiecare categorie. Se va afisa nnumele categoriei si numarul de filme.
Ordonati crescator rezultatul

SELECT g.gen_title AS Genre,


COUNT(m.mov_id) AS 'Number of movies'
FROM movies m
JOIN mov_genres mg ON m.mov_id = mg.mov_id
JOIN genres g ON mg.gen_id = g.gen_id
GROUP BY g.gen_title
ORDER BY COUNT(m.mov_id) asc;

-- Afisati ce categorii de filme a regizat Adam Sandler


SELECT *
FROM movies m
JOIN mov_genres mg ON m.mov_id = mg.mov_id
JOIN mov_dir md ON mg.mov_id = md.mov_id;

-- Afisati durata medie in minute pe categorie


SELECT g.gen_title AS Genre,
AVG(m.mov_time) AS AvgTIME
FROM movies m
JOIN mov_genres mg on m.mov_id = mg.mov_id
JOIN genres g on mg.gen_id = g.gen_id
GROUP BY g.gen_title;

-- Afisati durata medie in minute in care a jucat Tom Cruise


SELECT AVG(m.mov_time) as AVGTime
FROM movies m
JOIN movie_cast mc ON m.mov_id = mc.mov_id
JOIN actors a ON mc.act_id = a.act_id
WHERE a.act_firstname = 'Tom' AND a.act_lastname = 'Cruise';

You might also like