Advanced SQL Challenge: Using MOD()

365 Days of Daily Coding: Day 106

I rested and napped today. Isn’t it amazing that as an adult, you love napping more than anything? Oh, I also restarted my Korean classes which is a lot of fun. Although, I wonder when I would be able to speak fluently. I watch a lot of Korean movies and dramas. That has helped a lot with my learning. I know I could do more. The goal is to watch the dramas and movies without any subtitles. I think subtitles fail to deliver the nuances of the scene. This is generally applicable for all types of movies if you are not the native of the language.

Today I solved one part of the advanced sql challenge.

WITH temp AS (
Select 7 AS Seat FROM Dual Union All
Select 13 AS Seat FROM Dual Union All
Select 14 AS Seat FROM Dual Union All
Select 15 AS Seat FROM Dual Union All
Select 27 AS Seat FROM Dual Union All
Select 28 AS Seat FROM Dual Union All
Select 29 AS Seat FROM Dual Union All
Select 30 AS Seat FROM Dual Union All
Select 31 AS Seat FROM Dual Union All
Select 32 AS Seat FROM Dual Union All
Select 33 AS Seat FROM Dual Union All
Select 34 AS Seat FROM Dual Union All
Select 35 AS Seat FROM Dual Union All
Select 52 AS Seat FROM Dual Union All
Select 53 AS Seat FROM Dual Union All
Select 54 AS Seat FROM Dual 
)
SELECT Types, COUNT(*)
    FROM (
    SELECT 
    CASE WHEN MOD(Seat,2) <> 0 THEN 'ODD'
    ELSE 'EVEN'
    END Types from temp)
GROUP BY Types;

Leave a comment