SQL Project
SQL Project
-- Q4. Which city has the best customers? We would like to throw a promotional
Music
-- Festival in the city we made the most money. Write a query that returns one city
that
-- has the highest sum of invoice totals. Return both the city name & sum of all
invoice
-- totals
-- SELECT billing_city, SUM(total) AS total_invoice
-- FROM invoice
-- GROUP BY billing_city
-- ORDER BY total_invoice DESC
-- LIMIT 1
-- Q5. Who is the best customer? The customer who has spent the most money will be
-- declared the best customer. Write a query that returns the person who has spent
the
-- most money
-- SELECT C.first_name, C.last_name, SUM(I.total) AS money_spent
-- FROM customer AS C
-- LEFT JOIN invoice AS I
-- ON C.customer_id = I.customer_id
-- GROUP BY C.customer_id
-- ORDER BY money_spent DESC
-- LIMIT 1
-- Q2. Let's invite the artists who have written the most rock music in our
dataset. Write a
-- query that returns the Artist name and total track count of the top 10 rock
bands
-- Q3. Return all the track names that have a song length longer than the average
song length.
-- Return the Name and Milliseconds for each track. Order by the song length with
the
-- longest songs listed first
-- SELECT name, milliseconds
-- FROM track
-- WHERE milliseconds > (
-- SELECT AVG(milliseconds) AS avg_song_length
-- FROM track
-- )
-- ORDER BY milliseconds DESC