Practice Exercise On Chinook Part-1 Solution
Practice Exercise On Chinook Part-1 Solution
Using the chinook database, write SQLite queries to answer the following
questions in DB Browser.
select Title
from albums
where AlbumId=67;
Q.2 Find the name and length (in seconds) of all tracks that have length
between 50 and 70 seconds.
Q.3 List all the albums by artists with the word ‘black’ in their name.
select name
from artists
where name like "%black%"
Q.4 Provide a query showing a unique/distinct list of billing countries from the
Invoice table
SELECT DISTINCT BillingCountry
FROM invoices;
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Q.5 Display the city with highest sum total invoice.
SELECT BillingCity, round(sum(Total),2) as TotalInvoice
FROM invoices
group by BillingCity
ORDER by TotalInvoice DESC
limit 1;
Q.6 Produce a table that lists each country and the number of customers in
that country. (You only need to include countries that have customers) in
descending order. (Highest count at the top)
Q.7 Find the top five customers in terms of sales i.e. find the five customers
whose total combined invoice amounts are the highest. Give their name,
CustomerId and total invoice amount. Use join
Q.8 Find out state wise count of customerID and list the names of states with
count of customerID in decreasing order. Note:- do not include where states is
null value.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
select state, count( CustomerId) as counts
from customers
where state IS NOT NULL
group by State
order by counts desc;
Q.10 Provide a query showing only the Employees who are Sales Agents.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.