AnsweredAssumed Answered

Christmas SQL Challenge

Question asked by Joy Garon Employee on Dec 25, 2019
Latest reply on Jan 3, 2020 by Joy Garon

I want to calculate the total number of gifts from the song, The Twelve Days of Christmas. I have this code:

 

WITH myTally(n)
AS
(SELECT n = ROW_NUMBER() OVER (ORDER BY (SELECT null))
FROM (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10)) a(n)
CROSS JOIN (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10)) b(n)
)
SELECT SUM(x)
FROM myTally
WHERE n <= 1

 

With which piece of code should I replace SUM(x)?

A) SUM(n)
B) SUM(n*12)
C) SUM(n * (12-n))
D) SUM(n * (13-n))

Outcomes