Post date: May 06, 2014 11:22:18 AM
"Of the numbers from 1 to 100, what is the difference between the sum of the squares and the square of the sum?"
This is trivial.
WITH Ten(i) AS
(
SELECT 0
UNION ALL
SELECT i + 1
FROM Ten
WHERE i < 9
),
Integers(i) AS
(
SELECT 10 * t.i + o.i + 1
FROM Ten o
CROSS JOIN Ten t
)
SELECT POWER(SUM(i), 2) - SUM(POWER(i,2))
FROM Integers