Euler Project, Question 1
From PostgreSQL wiki
Jump to navigationJump to searchOne way to achieve the solution to question 1.
WITH RECURSIVE t1(a, b) AS (
VALUES(0,0)
UNION ALL
SELECT CASE CAST(b as boolean)
WHEN b % 3 = 0 THEN b
WHEN b % 5 = 0 THEN b
END,
b + 1
FROM t1
WHERE b < 1000
)
SELECT sum(a) FROM t1