0% found this document useful (0 votes)
9 views1 page

SQ5

The document contains examples of SQL queries with explanations. It includes queries to find director names who directed movies of a particular actor, movies without heroines, movies with the same runtime, the second latest movie release date, and actors with common last names.

Uploaded by

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

SQ5

The document contains examples of SQL queries with explanations. It includes queries to find director names who directed movies of a particular actor, movies without heroines, movies with the same runtime, the second latest movie release date, and actors with common last names.

Uploaded by

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

SQ5A - display the director names who directed movie of 'ajith'

- SELECT DIR_NAME,DIR_ID FROM DIRECTOR


WHERE DIR_ID IN(SELECT DIR_ID FROM MOVIE
WHERE MOV_ID IN(SELECT MOV_ID FROM STARS
WHERE ACT_ID IN(SELECT ACT_ID FROM ACTOR
WHERE ACT_FNAME='AJITH')));

SQ5B - Display movies where there is no "Heroine"


- SELECT MOV_TITLE FROM MOVIE
WHERE MOV_ID NOT IN(SELECT MOV_ID FROM STARS
WHERE ROLE IN('HEROINE')
GROUP BY MOV_ID);

SQ5C show movies having same run time


- SELECT MOV_TITLE, MOV_RUN_TIME FROM MOVIE
WHERE MOV_RUN_TIME IN(SELECT MOV_RUN_TIME FROM(SELECT
MOV_RUN_TIME,COUNT(MOV_RUN_TIME) FROM MOVIE
GROUP BY MOV_RUN_TIME
HAVING COUNT(MOV_RUN_TIME)>1))
ORDER BY MOV_RUN_TIME;

SQ5D Display second latest movie release date (without ORDER BY)
- SELECT MAX(MOV_RELEASE_DATE) from MOVIE
WHERE MOV_RELEASE_DATE<(SELECT MAX(MOV_RELEASE_DATE)
FROM MOVIE);

SQ5E Display actors who has common last names (Hint: Co-related subquery with
joins)
- SELECT ACT_FNAME,ACT_LNAME FROM ACTOR
WHERE ACT_LNAME IN (SELECT ACT_LNAME FROM(SELECT ACT_LNAME,COUNT(ACT_LNAME)
FROM ACTOR
GROUP BY ACT_LNAME
HAVING COUNT(ACT_LNAME)>1))
ORDER BY ACT_LNAME;

You might also like