Euler Project, Question 1
From PostgreSQL wiki
Revision as of 15:06, 19 May 2012 by Boshomi
One 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