Re: SQL CASE WHEN THEN ELSE END

David Raymond <[email protected]>
Newsgroups gmane.comp.db.sqlite.general
Message-ID <VI1PR07MB60299800781A9AE59C70AEE2870B0@VI1PR07MB6029.eurprd07.prod.outlook.com>
This is technically valid CASE syntax which is why you're not getting an error, it's just not what you're looking for.
...
CASE
(SELECT c.WYear FROM t2 WHERE pid = a.a)
WHEN c.WYear = 2020 THEN “YES” ELSE “NO” END
) AS DIGITAL
...

What that is saying is take the value you get from this:

(SELECT c.WYear FROM t2 WHERE pid = a.a)

and compare it to the value you get from this:

(c.WYear = 2020)

and if those two values match, then return the value of the field that's named "YES" (I'm assuming you wanted 'YES' there)

(c.WYear = 2020) is a perfectly valid expression... that's returning a boolean (well, int)
So you're comparing c.WYear (from the subquery) against a boolean.


(Others have replied with improved versions of the query, but for people following at home I figured I'd try to point out why the original version parsed ok and ran, just wasn't what you intended)

_______________________________________________
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.