aboutsummaryrefslogtreecommitdiff
path: root/challenge-085/abigail/sql/ch-1.sql
blob: 796f7f1a86fa8e8f4e7e05a28343a0f9f99fc90e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
--
--  See the file ch-1.table for the definition of the used table.
--
--  Assumes each number of the input is on a separate row.
-- 

SELECT COUNT(*) 
  FROM (SELECT  1
          FROM  Numbers t1,
                Numbers t2,
                Numbers t3
         WHERE  t1 . id > t2 . id 
           AND  t2 . id > t3 . id
           AND  1 < t1 . value + t2 . value + t3 . value
           AND      t1 . value + t2 . value + t3 . value < 2
         LIMIT  1)