Skip to content

Instantly share code, notes, and snippets.

@DorotejaMazej
Created February 19, 2017 22:35
Show Gist options
  • Select an option

  • Save DorotejaMazej/a50ea8e7cc9c3252faaf853e41aa78e5 to your computer and use it in GitHub Desktop.

Select an option

Save DorotejaMazej/a50ea8e7cc9c3252faaf853e41aa78e5 to your computer and use it in GitHub Desktop.
wd2_2-lesson
SELECT MAX(Invoice.Total)
FROM Invoice;
SELECT MIN(Invoice.Total)
FROM Invoice;
SELECT COUNT(Track.TrackId)
FROM Track
JOIN MediaType ON Track.MediaTypeId=MediaType.MediaTypeId
WHERE MediaType.Name='Protected AAC audio file';
SELECT Artist.Name, COUNT(Album.ArtistId) AS NumberOfAlbums
FROM Album
INNER JOIN Artist ON Album.ArtistId=Artist.ArtistId
GROUP BY Album.ArtistId
ORDER BY count(Album.ArtistId) DESC;
SELECT Genre.Name, COUNT(Track.GenreId)AS NumberOfSongs
FROM Track
INNER JOIN Genre ON Track.GenreId=Genre.GenreId
GROUP BY Track.GenreId
ORDER BY count(Track.GenreId) DESC;
SELECT Customer.FirstName, Customer.LastName, Invoice.Total,
MAX(Invoice.Total)
FROM Invoice
INNER JOIN Customer ON Invoice.CustomerId=Customer.CustomerId;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment