Guest User

Untitled

a guest
Nov 18th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. Name
  2. ----
  3. John
  4. Doe
  5. Mary
  6. Anon
  7.  
  8. Name | Artist | # of Tracks
  9. -------------------------------------
  10. Alb1 John 2
  11. Alb2 John 1
  12. Alb1 Doe 1
  13.  
  14. Album | Artist | Number | Title | Time
  15. -----------------------------------------
  16. Alb1 John 1 track1 60
  17. Alb2 John 1 track2 60
  18. Alb1 Doe 1 track1 60
  19.  
  20. Album | Artist | seconds
  21. --------------------------
  22. Alb2 John 60
  23. Alb1 Doe 60
  24.  
  25. SELECT distinct(albums.title), albums.artist, sum(tracks.length) as seconds
  26. FROM albums join tracks on tracks.artist = albums.artist
  27. WHERE albums.tracks >= tracks.number
  28. and albums.artist = tracks.artist
  29. group by albums.title, albums.artist
  30.  
  31. WHERE albums.tracks >= tracks.number
Add Comment
Please, Sign In to add comment