Guest User

Untitled

a guest
Dec 13th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. ```sql
  2. select publishingHouse.title, count(publishingHouse.title)
  3. from publishingHouse JOIN book ON publishingHouse.id=book.publishingHouse_id
  4. group by publishingHouse.title
  5. having count(publishingHouse.title) = (select max(publishingHouse.num) as max_count
  6. from (select publishingHouse.title, count(publishingHouse.title) as num
  7. from publishingHouse JOIN book ON publishingHouse.id=book.publishingHouse_id
  8. group by publishingHouse.id
  9. )
  10. publishingHouse
  11. );
  12.  
  13.  
  14.  
  15.  
  16. select publishingHouse.title
  17. from book
  18. JOIN author
  19. ON book.author_id = author.id
  20. JOIN publishingHouse
  21. ON book.publishingHouse_id = publishingHouse.id
  22. WHERE author.title NOT IN ('author1', 'author2')
  23.  
  24.  
  25.  
  26. select * from book
  27. where book.issueDate IS NULL
  28. having book.return_date = (
  29. select min(book.return_date) from book
  30. )
  31. ;
  32.  
  33.  
  34. select * from book
  35. where book.issueDate IS NULL AND book.return_date < CAST(CURRENT_DATE AS DATE)
  36. OR book.return_date < book.issueDate
  37. ;
  38. ```
Add Comment
Please, Sign In to add comment