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))

I don't know how to do it in SQL but the answer is 78. Seems overly complicated to do it in SQL, but hope you learn something.

1+2+3+4+5+6+7+8+9+10+11+12=78