365 Days of Daily Coding: Day 66
Today went by very fast. Is that a good thing? Although interms of productivity, I would say I was on average scale. I did manage to cross out one and half task out of the 4 task that I wanted to complete. The third task could not be completed because the system was done so there was nothing I could do.
I solved a medium challenge. The challenge is similar to one of the earlier challenges that I completed but this time around I used an INNER JOIN instead of relying only on one table.
WITH temp AS (
SELECT * FROM dates
WHERE month = 05
AND year = 2020
)
SELECT date_category, COUNT(*)
FROM (
SELECT CASE
WHEN counts >=100 THEN 'busy'
ELSE 'slow'
END AS date_category
FROM (
SELECT t.date, COUNT(r.rental_id) AS counts
FROM rental r RIGHT JOIN temp t
ON DATE(r.rental_ts) = t.date
GROUP BY t.date)
AS k)
AS l
GROUP BY date_category;

Leave a comment