365 Days of Daily Coding: Day 131
Manifesting that today’s going to be a fantastic day. I complete most of the task I set out to do. I eat healthy today and most importantly go for a walk. All my wishes come true. All my fears, be gone. I am happy, healthy and grateful. I am most importantly enough, talented and can accomplish anything I set out to. Cheers!
Puzzle 17: De-Grouping

I tried the solution in the live oracle environment here.
WITH temp AS
(Select 'Pencil' As Product, 3 As Quantity From Dual UNION ALL
Select 'Eraser' As Product, 4 As Quantity From Dual UNION ALL
Select 'Notebook' As Product, 2 As Quantity From Dual
), temp2 AS
( Select 1 AS Counts, 1 AS Id From Dual UNION ALL
Select 1 AS Counts, 2 AS Id From Dual UNION ALL
Select 1 AS Counts, 3 AS Id From Dual UNION ALL
Select 1 AS Counts, 4 AS Id From Dual
)
SELECT temp.Product, temp2.Counts
FROM temp2 CROSS JOIN temp
WHERE temp2.id <= temp.Quantity
ORDER BY Product DESC;

Leave a comment