Re: SQL CASE WHEN THEN ELSE END

Simon Slavin <[email protected]>
Newsgroups gmane.comp.db.sqlite.general
Message-ID <[email protected]>
On 27 Jan 2020, at 2:44am, Jose Isaias Cabrera <[email protected]> wrote:

> CASE
>    (
>          SELECT WYear FROM t2 WHERE pid = a.a
>    )
>    WHEN c.WYear = 2020 THEN “YES”
>    ELSE “NO” END

That's not the structure of a CASE statement.

After CASE comes an expression.
After WHEN comes another expression.
If they equal one another, then the the bit after the THEN is returned.

You want something more like

SELECT 
    (CASE WYear WHEN 2020 THEN 'YES' ELSE 'NO' END) AS DIGITAL
    FROM t2 WHERE pid = a.a

but you'll have to fit this in with how your overall SELECT works.

Sse "The CASE expression" on this page for more details:

<https://sqlite.org/lang_expr.html>

Also note that to quote strings you use a single apostrophe at both ends, not directed speech marks, just as you had in your INSERT commands.
_______________________________________________
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.