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

Query of SQL Codes of Udacity Music Store

The document contains SQL queries to retrieve top performers in various categories from a music database. It includes queries for the best artists based on sales, best genres by revenue, best customers by total spending, and best employees by number of sales and total sales. Each query groups results and orders them to show the top entries in each category.

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)
31 views1 page

Query of SQL Codes of Udacity Music Store

The document contains SQL queries to retrieve top performers in various categories from a music database. It includes queries for the best artists based on sales, best genres by revenue, best customers by total spending, and best employees by number of sales and total sales. Each query groups results and orders them to show the top entries in each category.

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

/*BEST ARTIST*/

SELECT [Link],SUM([Link]) Sales


FROM Artist Ar
Join Album Al
ON [Link] = [Link]
Join Track T
ON [Link]=[Link]
GROUP BY [Link]
ORDER BY Sales DESC
LIMIT 10;

/*BEST GENER*/
SELECT [Link],SUM([Link]) High_revenue_For_gener
From Genre G
JOIN Track T
ON [Link]=[Link]
GROUP BY [Link]
ORDER By High_revenue_For_gener DESC
LIMIT 10;

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

/*BEST EMPLOYEE*/
SELECT [Link],[Link] || " " || [Link] Name,COUNT(*)
num_of_sales,SUM([Link]) Total_sales
FROM Invoice I
JOIN Customer C
ON [Link] = [Link]
JOIN Employee E
ON [Link]=[Link]
Group BY Name
ORDER BY Total_sales DESC

You might also like