Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
lab1-1MAC-DATA ANALYSIS TRACK
test1
Q1
The Chinook database contains all invoices from the beginning of 2009 till the end of 2013. The employees at Chinook store are interested in seeing all invoices that happened in 2013 only. Using the Invoice table, write a query that returns all the info of the invoices in 2013.
SL1:
SELECT *
FROM Invoice
WHERE InvoiceDate BETWEEN '2013-01-01' AND '2014-01-01' ;
Q2
The Chinook team decided to run a marketing campaign in Brazil, Canada, india, and Sweden. They will start with the country that has the least customers. Using the customer table, write a query that returns the first name, last name, and country for all customers from the 4 countries
SL2!
SELECT FirstName, LastName, Country
FROM Customer
WHERE Country IN ('Brazil', 'Canada', 'India', 'Sweden');
Q3
Using the Track and Album tables, write a query that returns all the songs that start with the letter 'A' and the composer field is not empty. Your query should return the name of the song, the name of the composer, and the title of the album.
SL3:
SELECT t.Name,t.Composer,a.Title
FROM Album as a
JOIN Track as t
ON t.AlbumId=a.AlbumId
WHERE t.Name LIKE 'A%' AND t.Composer IS NOT NULL ;
Q4
The Chinook team would like to throw a promotional Music Festival for their top 10 cutomers who have spent the most in a single invoice. Write a query that returns the first name, last name, and invoice total for the top 10 invoices ordered by invoice total descending.
SL4:
SELECT c.FirstName ,c.LastName, i.Total
FROM Customer c
JOIN Invoice i
ON c.customerid = i.customerid
ORDER BY i.Total DESC LIMIT 10 ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.