365 Days of Daily Coding Challenge: Day 87
This coding challenge has been the only constant fuel in my pandemic life so far. I feel like that energy has sparked various other areas of my life. For instance, 15 minutes exercise in the morning. I hate exercising and like this daily challenge, I strive to atleast exercise for few mins in the morning. It has been especially helpful with my backaches which tends to get worse towards the evening. Forming new habit is not easy and there are times when I skip but I do rebound as is the case for this coding challenge. 😂
WITH temp AS (
SELECT a.district, COUNT(c.customer_id)
FROM address a LEFT JOIN customer c
ON a.address_id = c.address_id
GROUP BY a.district)
SELECT * FROM
(
SELECT district,
CASE WHEN count = (SELECT MAX(count) FROM temp) THEN 'most'
WHEN count = (SELECT MIN(count) FROM temp) THEN 'least'
ELSE null
END AS city_cat
FROM temp) AS k
WHERE city_cat IS NOT null;

Leave a comment