Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. .headers ON
  2. .mode column
  3.  
  4. --select Battles.name as battleName, date, count(distinct classes.country) as numberOfCountries
  5. --from Battles
  6. --join outcomes on Battles.name = outcomes.battle
  7. --join Ships on Ships.name = outcomes.ship or Ships.name = outcomes.sunkBy
  8. --join classes on classes.class = ships.class
  9. --group by battleName;
  10.  
  11. --select battle, count(distinct country)
  12. --from classes,ships,outcomes
  13. --where (name=ship or name = sunkBy) and ships.class = classes.class
  14. --group by battle;
  15.  
  16. --select avg(numGuns)
  17. --from ships
  18. --natural join classes
  19. --where name not in (select ship from outcomes where result is 'sunk');
  20.  
  21. --Lausn 1 f. daemi c
  22. --create temp view classesMoreThan2 as
  23. ----select class, count(class) as numberOfShips
  24. ----from ships
  25. ----group by class
  26. ----having numberOfShips >= 2;
  27.  
  28. --select ships.class, count(ships.class) as shipsSunk
  29. --from ships
  30. --natural join classesMoreThan2
  31. --join outcomes on outcomes.sunkBy = ships.name
  32. --group by ships.class;
  33.  
  34. --Lausn 2 f daemi c
  35. --create temp view sc as
  36. ----select classes.class, count(ships.name)
  37. ----from classes,ships --
  38. ----where classes.class=ships.class
  39. ----group by classes.class
  40. ----having count(ships.name) >= 2;
  41.  
  42. --select sc.class, count(outcomes.sunkby)
  43. --from sc, ships, outcomes
  44. --where sc.class=ships.class and outcomes.ship = ships.name
  45. --group by sc.class;
  46.  
  47. --select sunkBy as sinker from outcomes where sunkBy is not NULL and sunkBy is not 'NULL';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement