Re: SQL CASE WHEN THEN ELSE END

Jose Isaias Cabrera <[email protected]>
Newsgroups gmane.comp.db.sqlite.general
Message-ID <VI1P195MB0765A2242546C983DD7D3A46DE0B0@VI1P195MB0765.EURP195.PROD.OUTLOOK.COM>
Jose Isaias Cabrera, on Monday, January 27, 2020 08:42 AM, wrote...
>
>
> Keith Medcalf, on Monday, January 27, 2020 04:02 AM, wrote...

This is actually what I need:

SELECT a.a,
         a.c,
         a.e,
         b.g,
         b.h,
         b.i,
         coalesce((
                   SELECT 'YES'
                     FROM t2
                    WHERE wYear == a.c
                      AND pid == a.a
                  ),  'NO') AS digital
    FROM t0 as a, t1 as b
   WHERE a.a == b.f
     AND a.idate == (SELECT MAX(idate) from t0 where a = a.a)
     AND b.idate == (SELECT MAX(idate) from t1 where f = a.a)
     AND a.c == 2020
;

Because there are other records that are in the other databases, but not in t2, which still need to be part of the result.  Thanks for everything Igor, Keith, Simon, and everyone who thought about it. ;-)

josé
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.