SlideShare une entreprise Scribd logo
1  sur  2
Télécharger pour lire hors ligne
‘Movies’
Questions
The ‘Movies’ database contains four tables:
Movie (movieID, movname, length, year, dirID)
Director (dirID, dirname, country)
Member (memberID, memname, address, owes)
Onhire (movieID, memberID, duedate)
All fields are text except length, year and owes (number), and duedate (date).
Create and save SQL queries for the following:
Use JOINS to answer these questions:
1. How much is owed by members who currently have movies on hire?
List in order of amount owing.
2. List directors of movies made in 1986 or 1987.
3. What is the name and address of members who have movies due on
or before the 8th of September?
4. Who currently has Zulu on hire?
5. What are the names of the movies on hire to the member who currently
owes the most?
6. Who directed the movie L. Austin has on hire?
It is possible to join a table to itself. This can only be done by using
different aliases for the same table.
E.g.: Show any members who have the same address.
Enter the following SQL query to verify it produces the desired result:
select M1.memname, M2.memname, M1.address
from Member M1, Member M2
where M1.address = M2.address
and M1.memberID < M2.memberID
Why do you think the last line is needed? Delete it and see what
difference it makes.

7. List any movies by a director that are the same length in time.
8. What are the names of movies that are rented by members who have
more than one movie due on the same day? (Good luck!)
Use SUBQUERIES to answer these questions:
9. What country is the director of Casablanca from?
10. What is the name and address of the member hiring movie 1015?
11. How much is owed by the member with videos due on 6th September?
12. Who directed Glory?
13. Which movies (numbers) are on hire to members who do not owe
anything? (HINT: use ‘is null’ in the WHERE clause)
14. What movies (names) are being hired by R Miller?
15. What is the address of the member who has Full Metal Jacket on hire?
16. List the directors of movies due back on the 12th of September.

Contenu connexe

En vedette

Ekonomi paramedik tukenmislik
Ekonomi paramedik tukenmislikEkonomi paramedik tukenmislik
Ekonomi paramedik tukenmislikGurkan Ersoy
 
Focus group questions
Focus group questions Focus group questions
Focus group questions kayleighb96
 
Nove em cada dez consumidores virtuais consultam a internet antes de realizar...
Nove em cada dez consumidores virtuais consultam a internet antes de realizar...Nove em cada dez consumidores virtuais consultam a internet antes de realizar...
Nove em cada dez consumidores virtuais consultam a internet antes de realizar...SPC Brasil
 
Eλληνων ιχνη στην Bενετια - Bενετών αποτυπώματα στην Ελλάδα 2015
Eλληνων   ιχνη   στην   Bενετια -  Bενετών  αποτυπώματα στην Ελλάδα 2015Eλληνων   ιχνη   στην   Bενετια -  Bενετών  αποτυπώματα στην Ελλάδα 2015
Eλληνων ιχνη στην Bενετια - Bενετών αποτυπώματα στην Ελλάδα 2015eythymia
 
Quiz sobre el fútbol fran serrano
Quiz sobre el fútbol fran serranoQuiz sobre el fútbol fran serrano
Quiz sobre el fútbol fran serranofransdt1599
 
Surviving the Wilderness
Surviving the WildernessSurviving the Wilderness
Surviving the WildernessBradley Riley
 
Capebe - Informativo - Maio - 13.05.15
 Capebe - Informativo - Maio - 13.05.15 Capebe - Informativo - Maio - 13.05.15
Capebe - Informativo - Maio - 13.05.15Capebe Cooperativa
 
Service2Fruit-Corporate-v1
Service2Fruit-Corporate-v1Service2Fruit-Corporate-v1
Service2Fruit-Corporate-v1Randy Dijksman
 
Pm sql exercises
Pm sql exercisesPm sql exercises
Pm sql exerciseshccit
 

En vedette (14)

Ekonomi paramedik tukenmislik
Ekonomi paramedik tukenmislikEkonomi paramedik tukenmislik
Ekonomi paramedik tukenmislik
 
Focus group questions
Focus group questions Focus group questions
Focus group questions
 
Nove em cada dez consumidores virtuais consultam a internet antes de realizar...
Nove em cada dez consumidores virtuais consultam a internet antes de realizar...Nove em cada dez consumidores virtuais consultam a internet antes de realizar...
Nove em cada dez consumidores virtuais consultam a internet antes de realizar...
 
Eλληνων ιχνη στην Bενετια - Bενετών αποτυπώματα στην Ελλάδα 2015
Eλληνων   ιχνη   στην   Bενετια -  Bενετών  αποτυπώματα στην Ελλάδα 2015Eλληνων   ιχνη   στην   Bενετια -  Bενετών  αποτυπώματα στην Ελλάδα 2015
Eλληνων ιχνη στην Bενετια - Bενετών αποτυπώματα στην Ελλάδα 2015
 
La materia y propiedades
La materia y propiedadesLa materia y propiedades
La materia y propiedades
 
Quiz sobre el fútbol fran serrano
Quiz sobre el fútbol fran serranoQuiz sobre el fútbol fran serrano
Quiz sobre el fútbol fran serrano
 
Calaméo
CalaméoCalaméo
Calaméo
 
Surviving the Wilderness
Surviving the WildernessSurviving the Wilderness
Surviving the Wilderness
 
Reflection unit 2
Reflection unit 2Reflection unit 2
Reflection unit 2
 
Capebe - Informativo - Maio - 13.05.15
 Capebe - Informativo - Maio - 13.05.15 Capebe - Informativo - Maio - 13.05.15
Capebe - Informativo - Maio - 13.05.15
 
Service2Fruit-Corporate-v1
Service2Fruit-Corporate-v1Service2Fruit-Corporate-v1
Service2Fruit-Corporate-v1
 
Navy day
Navy dayNavy day
Navy day
 
Folleto ganso iberico
Folleto ganso ibericoFolleto ganso iberico
Folleto ganso iberico
 
Pm sql exercises
Pm sql exercisesPm sql exercises
Pm sql exercises
 

Plus de hccit

Snr ipt 10_syll
Snr ipt 10_syllSnr ipt 10_syll
Snr ipt 10_syllhccit
 
Snr ipt 10_guide
Snr ipt 10_guideSnr ipt 10_guide
Snr ipt 10_guidehccit
 
3 d modelling_task_sheet_2014_yr12
3 d modelling_task_sheet_2014_yr123 d modelling_task_sheet_2014_yr12
3 d modelling_task_sheet_2014_yr12hccit
 
3 d modelling_task_sheet_2014_yr11
3 d modelling_task_sheet_2014_yr113 d modelling_task_sheet_2014_yr11
3 d modelling_task_sheet_2014_yr11hccit
 
10 ict photoshop_proj_2014
10 ict photoshop_proj_201410 ict photoshop_proj_2014
10 ict photoshop_proj_2014hccit
 
Photoshop
PhotoshopPhotoshop
Photoshophccit
 
Flash
FlashFlash
Flashhccit
 
University partnerships programs email
University partnerships programs emailUniversity partnerships programs email
University partnerships programs emailhccit
 
Griffith sciences pathway programs overview
Griffith sciences pathway programs overviewGriffith sciences pathway programs overview
Griffith sciences pathway programs overviewhccit
 
Griffith info tech brochure
Griffith info tech brochureGriffith info tech brochure
Griffith info tech brochurehccit
 
Repairs questions
Repairs questionsRepairs questions
Repairs questionshccit
 
Australian birds questions
Australian birds questionsAustralian birds questions
Australian birds questionshccit
 
Section b
Section bSection b
Section bhccit
 
Section a
Section aSection a
Section ahccit
 
Ask manual rev5
Ask manual rev5Ask manual rev5
Ask manual rev5hccit
 
Case study report mj
Case study report mjCase study report mj
Case study report mjhccit
 
Mj example case_study_layout_intro_completedq
Mj example case_study_layout_intro_completedqMj example case_study_layout_intro_completedq
Mj example case_study_layout_intro_completedqhccit
 
Case study plan mj
Case study plan mjCase study plan mj
Case study plan mjhccit
 

Plus de hccit (20)

Snr ipt 10_syll
Snr ipt 10_syllSnr ipt 10_syll
Snr ipt 10_syll
 
Snr ipt 10_guide
Snr ipt 10_guideSnr ipt 10_guide
Snr ipt 10_guide
 
3 d modelling_task_sheet_2014_yr12
3 d modelling_task_sheet_2014_yr123 d modelling_task_sheet_2014_yr12
3 d modelling_task_sheet_2014_yr12
 
3 d modelling_task_sheet_2014_yr11
3 d modelling_task_sheet_2014_yr113 d modelling_task_sheet_2014_yr11
3 d modelling_task_sheet_2014_yr11
 
10 ict photoshop_proj_2014
10 ict photoshop_proj_201410 ict photoshop_proj_2014
10 ict photoshop_proj_2014
 
Photoshop
PhotoshopPhotoshop
Photoshop
 
Flash
FlashFlash
Flash
 
University partnerships programs email
University partnerships programs emailUniversity partnerships programs email
University partnerships programs email
 
Griffith sciences pathway programs overview
Griffith sciences pathway programs overviewGriffith sciences pathway programs overview
Griffith sciences pathway programs overview
 
Griffith info tech brochure
Griffith info tech brochureGriffith info tech brochure
Griffith info tech brochure
 
Repairs questions
Repairs questionsRepairs questions
Repairs questions
 
Australian birds questions
Australian birds questionsAustralian birds questions
Australian birds questions
 
Section b
Section bSection b
Section b
 
B
BB
B
 
A
AA
A
 
Section a
Section aSection a
Section a
 
Ask manual rev5
Ask manual rev5Ask manual rev5
Ask manual rev5
 
Case study report mj
Case study report mjCase study report mj
Case study report mj
 
Mj example case_study_layout_intro_completedq
Mj example case_study_layout_intro_completedqMj example case_study_layout_intro_completedq
Mj example case_study_layout_intro_completedq
 
Case study plan mj
Case study plan mjCase study plan mj
Case study plan mj
 

Movies questions

  • 1. ‘Movies’ Questions The ‘Movies’ database contains four tables: Movie (movieID, movname, length, year, dirID) Director (dirID, dirname, country) Member (memberID, memname, address, owes) Onhire (movieID, memberID, duedate) All fields are text except length, year and owes (number), and duedate (date). Create and save SQL queries for the following: Use JOINS to answer these questions: 1. How much is owed by members who currently have movies on hire? List in order of amount owing. 2. List directors of movies made in 1986 or 1987. 3. What is the name and address of members who have movies due on or before the 8th of September? 4. Who currently has Zulu on hire? 5. What are the names of the movies on hire to the member who currently owes the most? 6. Who directed the movie L. Austin has on hire?
  • 2. It is possible to join a table to itself. This can only be done by using different aliases for the same table. E.g.: Show any members who have the same address. Enter the following SQL query to verify it produces the desired result: select M1.memname, M2.memname, M1.address from Member M1, Member M2 where M1.address = M2.address and M1.memberID < M2.memberID Why do you think the last line is needed? Delete it and see what difference it makes. 7. List any movies by a director that are the same length in time. 8. What are the names of movies that are rented by members who have more than one movie due on the same day? (Good luck!) Use SUBQUERIES to answer these questions: 9. What country is the director of Casablanca from? 10. What is the name and address of the member hiring movie 1015? 11. How much is owed by the member with videos due on 6th September? 12. Who directed Glory? 13. Which movies (numbers) are on hire to members who do not owe anything? (HINT: use ‘is null’ in the WHERE clause) 14. What movies (names) are being hired by R Miller? 15. What is the address of the member who has Full Metal Jacket on hire? 16. List the directors of movies due back on the 12th of September.