0% found this document useful (0 votes)
22 views1 page

Query of SQL Codes of Udacity Music Store

Uploaded by

Amira Khaled
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views1 page

Query of SQL Codes of Udacity Music Store

Uploaded by

Amira Khaled
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

/*BEST ARTIST*/

SELECT Ar.Name,SUM(T.UnitPrice) Sales


FROM Artist Ar
Join Album Al
ON Ar.ArtistId = Al.ArtistId
Join Track T
ON Al.AlbumId=T.AlbumId
GROUP BY Ar.Name
ORDER BY Sales DESC
LIMIT 10;

/*BEST GENER*/
SELECT G.Name,SUM(T.UnitPrice) High_revenue_For_gener
From Genre G
JOIN Track T
ON G.GenreId=T.GenreId
GROUP BY G.Name
ORDER By High_revenue_For_gener DESC
LIMIT 10;

/*BEST CUSTOMer*/
SELECT C.FirstName || " " || C.LastName Name, SUM (I.total) Total_spent
FROM Customer C
JOIN Invoice I
ON C.CustomerId = I.CustomerId
GROUP BY FirstName
ORDER BY Total_spent DESC
LIMIT 15;

/*BEST EMPLOYEE*/
SELECT C.SupportRepId,E.FirstName || " " || E.LastName Name,COUNT(*)
num_of_sales,SUM(I.Total) Total_sales
FROM Invoice I
JOIN Customer C
ON C.CustomerId = I.CustomerId
JOIN Employee E
ON C.SupportRepId=E.EmployeeId
Group BY Name
ORDER BY Total_sales DESC

You might also like