Hi,

Using SQLite version 3.15.2, the following SQL returns 0 rows, whereas I believe it should return 1 row. Any of the commented out alternatives produces the expected 1 row.


Mark

CREATE VIEW W AS
    SELECT 0 show_a;

CREATE VIEW X AS
            SELECT   'A' a,  1 v
    UNION SELECT 'B',    1;

CREATE VIEW Y AS
    SELECT * FROM W JOIN X;

SELECT CASE WHEN group_by_a THEN a END a, SUM(v) v
FROM Y
LEFT JOIN (SELECT NULL group_by_a UNION SELECT 1) x2
       ON show_a  AND a IS NOT NULL
      --ON show_a = 1   AND  a IS NOT NULL
      -- ON IFNULL(show_a, 0)  AND  a IS NOT NULL
      --ON NOT(NOT(show_a)) AND  a IS NOT NULL
 GROUP BY  CASE WHEN group_by_a THEN a END;
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to