365 Days of Daily Coding: Day 81
I had a migraine at the right side of brain yesterday and was unable to post. I was reflecting back at the number of times I couldn’t post although it’s meant to be a daily challenge. The past me would have nagged myself to death. Now, as I grow wiser, I try not to think of the ideal state but instead of the process. I keep in mind that picking myself up after falling is more important than the perfectionism I used to chase after.
SELECT * FROM
(SELECT *, ntile(100) OVER (ORDER BY revenue) AS percentile
FROM (
SELECT f.film_id, SUM(p.amount) AS revenue
FROM film f JOIN inventory i
ON f.film_id = i.film_id
LEFT JOIN rental r
ON i.inventory_id = r.inventory_id
LEFT JOIN payment p
ON r.rental_id = p.rental_id
GROUP BY f.film_id) AS k) AS l
WHERE film_id IN (1,10,11,20,21,30);

Leave a comment