Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.05 KB | None | 0 0
  1. 1
  2. use lab1;
  3. select name,cost,sum(amount) from book
  4. join lot on bookid=fk_lot_book
  5. where YEAR(date_form) = 2013
  6. group by name,cost;
  7. 2
  8. use lab1;
  9. select pub_name, name from pub_house
  10. join lot on pub_id=fk_lot_pub
  11. join book on fk_lot_book=bookid
  12. where YEAR(date_form) = 2013
  13. group by pub_name,name;
  14. 3
  15. use lab1;
  16. select name,genre,author from book
  17. join lot on bookid=fk_lot_book
  18. where cost = (select MAX(cost) from lot)
  19. group by name;
  20. 4
  21. use lab1;
  22. select pub_name,name,sum(sum_cost),sum(amount) from pub_house
  23. join lot on pub_id=fk_lot_pub
  24. join book on bookid=fk_lot_book
  25. group by pub_name,name;
  26. 5
  27. use lab1;
  28. select * from pub_house
  29. left join lot on pub_id=fk_lot_pub
  30. where lot_id is NULL;
  31. 6
  32. use lab1;
  33. select * from pub_house
  34. where pub_id not in(select fk_lot_pub from lot where YEAR(date_form) = 2013)
  35. group by pub_name;
  36. 7
  37. use lab1;
  38. create view v as
  39. select pub_house.pub_name,pub_house.city,pub_house.contract_num,pub_house.contract_date,count(lot.fk_lot_book)
  40. from pub_house,lot
  41. where fk_lot_pub=pub_id
  42. group by pub_name;
  43.  
  44. select * from v;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement