1. SELECT T.[Planet's Name] from Timetable T Where T.[Character's Name] = 'R2-D2' and T.Movie = 3
Total Page:16
File Type:pdf, Size:1020Kb
1. SELECT T.[planet's name] FROM TimeTable T Where T.[character's name] = 'R2-D2' AND T.movie = 3 planet's name Dagobah Endor 2. SELECT Count(*) AS [number of people visit Tatooine] FROM (SELECT DISTINCT T.[Character's name] FROM TimeTable T WHERE (((T.[Planet's Name])='Tatooine') AND ((T.Movie)=3))); number of people visit Tatooine 8 3. SELECT T.[Character's name] FROM TimeTable T,Characters C WHERE T.[Character's name] = C.name AND C.Homeworld = T.[Planet's name] AND T.Movie=1; Character's name Luke Skywalker Obi-Wan Kanobi Owen Lars 4. SELECT C.name FROM Characters C WHERE NOT EXISTS ( SELECT P.name FROM Planets P WHERE P.Affiliation = 'neutral' AND P.name NOT IN ( SELECT T.[Planet's name] FROM TimeTable T Where T.[character's name] = C.name AND T.[Planet's name] = P.name ) ); name Luke Skywalker 5. SELECT DISTINCT T.[Planet's name] FROM characters C, timetable T Where C.Affiliation = 'empire' AND T.[Character's name] = C.name Planet's name Bespin Death Star Hoth Star Destroyer 6. SELECT C.name, P.name, SUM(T.[Time of Departure] - T.[Time of Arrival]) AS [Total time] FROM characters C, planets P, timetable T Where P.Affiliation = 'neutral' AND T.[character's name] = C.name AND T.[Planet's name] = P.name GROUP BY C.name, P.name (result of 6 is at next page) (result of 6) C.name P.name Total time C-3 PO Bespin 4 C-3 PO Tatooine 4 Chewbacca Bespin 4 Chewbacca Endor 5 Chewbacca Tatooine 4 Darth Vader Bespin 5 Han Solo Bespin 4 Han Solo Endor 5 Han Solo Tatooine 4 Jabba the Hutt Tatooine 22 Lando Calrissian Bespin 9 Lando Calrissian Endor 1 Lando Calrissian Tatooine 2 Luke Skywalker Bespin 2 Luke Skywalker Dagobah 5 Luke Skywalker Endor 3 Luke Skywalker Tatooine 3 Obi-Wan Kanobi Tatooine 2 Owen Lars Tatooine 1 Princess Leia Bespin 4 Princess Leia Endor 5 Princess Leia Tatooine 2 R2-D2 Bespin 2 R2-D2 Dagobah 5 R2-D2 Endor 3 Rancor Tatooine 23 Yoda Dagobah 25 7. SELECT DISTINCT T1.[Planet's name],T1.movie FROM timetable T1,timetable T2 Where T1.[character's name] = 'Luke Skywalker' AND T2.[character's name] = 'Darth Vader' AND T1.movie = T2.movie AND T1.[Planet's name] = T2.[Planet's name] AND ( (T1.[Time of Arrival] >= T2.[Time of Arrival] AND T1.[Time of Arrival] <= T2.[Time of Departure]) OR (T2.[Time of Arrival] >= T1.[Time of Arrival] AND T2.[Time of Arrival] <= T1.[Time of Departure]) ) Planet's name movie Bespin 2 Death Star 1 Death Star 3 Star Destroyer 1 8. SELECT DISTINCT T.movie,T.[Character's name] From Timetable T, Planets P, Characters C Where( P.type = 'desert' AND T.[Planet's name] = P.name AND C.race = 'human' AND T.[Character's name] = C.name ) OR ( P.type = 'swamp' AND T.[Planet's name] = P.name AND C.race = 'droid' AND T.[Character's name] = C.name ) ORDER BY T.movie,T.[Character's name] (result of 8 is at next page) (result of 8) movie Character's name 1 Han Solo 1 Luke Skywalker 1 Obi-Wan Kanobi 1 Owen Lars 2 R2-D2 3 Han Solo 3 Lando Calrissian 3 Luke Skywalker 3 Princess Leia 3 R2-D2 9. SELECT F2.[character's name],F1.movie from ( SELECT max(E.[times to different plant]) AS BIG,E.movie from ( SELECT t.[character's name], count(t.[planet's name]) AS [times to different plant], t.movie from timetable t GROUP BY t.movie, t.[character's name] )AS E GROUP BY E.movie )AS F1, ( SELECT t.[character's name], count(t.[planet's name]) AS [times to different plant], t.movie from timetable t GROUP BY t.movie, t.[character's name] )AS F2 Where F1.BIG = F2.[times to different plant] AND F1.movie = F2.movie character's name movie Luke Skywalker 1 Luke Skywalker 2 R2-D2 2 Luke Skywalker 3 10. Select P.name From Planets P Where P.name Not In ( Select T.[Planet's name] From Timetable T ) name Kashyyyk Corellia Alderaan 11. Select DISTINCT T1.[character's name] From Timetable T1 Where T1.movie = 1 AND T1.[character's name] In( Select T2.[character's name] From Timetable T2 Where T2.movie = 2 AND T2.[character's name] In( Select T3.[character's name] From Timetable T3 Where T3.movie = 3 ) ) character's name C-3 PO Chewbacca Darth Vader Han Solo Jabba the Hutt Luke Skywalker Princess Leia Rancor Yoda 12. Select F2.[Planet's name], F2.movie From( Select E.movie, max(E.[total time]) AS BIG From( Select T.[Planet's name],T.movie,(T.[Time of Departure]-T.[Time of Arrival]) AS [total time] From TimeTable T, Planets P, Characters C Where T.[Character's name] = 'Luke Skywalker' AND C.name = 'Luke Skywalker' AND T.[Planet's name] = P.name AND NOT P.Affiliation = C.Affiliation ) AS E GROUP BY T.movie ) AS F1,( Select T.[Planet's name],T.movie,(T.[Time of Departure]-T.[Time of Arrival]) AS [total time] From TimeTable T, Planets P, Characters C Where T.[Character's name] = 'Luke Skywalker' AND C.name = 'Luke Skywalker' AND T.[Planet's name] = P.name AND NOT P.Affiliation = C.Affiliation ) AS F2 Where F1.movie = F2.movie AND F1.BIG = F2.[total time] Planet's name movie Tatooine 1 Star Destroyer 1 Dagobah 2 Endor 3 13. Select T2.[Character's name] From Timetable T1,Timetable T2 Where T1.[Planet's name] = 'Star Destroyer' AND T2.[Planet's name] = 'Star Destroyer' AND T1.[Character's name] = 'Obi-Wan Kanobi' AND T1.movie = T2.movie AND T2.[Time of Arrival] < T1.[Time of Arrival] AND T2.[Time of Departure] > T1.[Time of Departure] Character's name Darth Vader 14. Select C.name From Characters C Where C.Affiliation = 'rebels' AND C.Race = 'Human' AND NOT C.Homeworld = 'Unknown' name Han Solo Princess Leia Luke Skywalker Obi-Wan Kanobi 15. Select P.name From Planets P Where P.name Not In ( Select DISTINCT T1.[Planet's name] From Timetable T1,Timetable T2,Timetable T3 Where Not T1.[Character's name] = T2.[Character's name] AND Not T1.[Character's name] = T3.[Character's name] AND Not T2.[Character's name] = T3.[Character's name] AND T1.[Planet's name] = T2.[Planet's name] AND T2.[Planet's name] = T3.[Planet's name] ) name Death Star Kashyyyk Corellia Alderaan .