KEMBAR78
Subqueries Solution 2 SQL Code | PDF
0% found this document useful (0 votes)
10 views1 page

Subqueries Solution 2 SQL Code

The document contains two SQL queries. The first query selects the first name, last name, and date of birth of the oldest actors for each gender. The second query retrieves the movie name, movie length, and age certificate for movies that have a length above the average for their respective age certificates.

Uploaded by

Wipro pvt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Subqueries Solution 2 SQL Code

The document contains two SQL queries. The first query selects the first name, last name, and date of birth of the oldest actors for each gender. The second query retrieves the movie name, movie length, and age certificate for movies that have a length above the average for their respective age certificates.

Uploaded by

Wipro pvt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 1

-- 1.

Select the first name, last name and date of birth for the oldest actors of each
gender.

SELECT ac1.first_name, ac1.last_name, ac1.date_of_birth FROM actors ac1


WHERE ac1.date_of_birth =
(SELECT MIN(ac2.date_of_birth) FROM actors ac2
WHERE ac2.gender = ac1.gender);

-- 2. Select the movie name, movie length and age certificate for movies with an
-- above average length for their age certificate.

SELECT mo1.movie_name, mo1.movie_length, mo1.age_certificate FROM movies


mo1
WHERE movie_length >
(SELECT AVG(mo2.movie_length) FROM movies mo2
WHERE mo2.age_certificate = mo1.age_certificate)
ORDER BY mo1.age_certificate;

You might also like