Here is another simplification of the script that avoids the use of LEFT JOIN and silly constructs like a GROUP BY on a PRIMARY KEY:

<blockquote><pre>
CREATE TABLE t1 (
  id1 INTEGER,
  value1 INTEGER,
  x1 INTEGER
);
INSERT INTO t1 VALUES(4469,2,98),(4469,1,99),(4469,3,97);
CREATE TABLE t2 (
  value2 INTEGER
);
INSERT INTO t2 VALUES(1);
pragma vdbe_listing=on; pragma vdbe_trace=on;
SELECT
 (SELECT sum(value2==xyz) FROM t2)
FROM
 (SELECT value1 as xyz, max(x1) AS pqr
    FROM t1
   GROUP BY id1);