Re: [sqlite] SQL CASE WHEN THEN ELSE END

2020-01-27 Thread Jose Isaias Cabrera
David Raymond, on Monday, January 27, 2020 10:32 AM, wrote... [clip] > (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. Yep, this little bit I knew. :-) > (Others have replied with i

Re: [sqlite] SQL CASE WHEN THEN ELSE END

2020-01-27 Thread David Raymond
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

Re: [sqlite] SQL CASE WHEN THEN ELSE END

2020-01-27 Thread Jose Isaias Cabrera
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 'Y

Re: [sqlite] SQL CASE WHEN THEN ELSE END

2020-01-27 Thread Jose Isaias Cabrera
Keith Medcalf, on Monday, January 27, 2020 04:02 AM, wrote... > > > This version generates the most efficient query plan in 3.31.0 when you > have indexes on the necessary columns: > > CREATE INDEX t0_1 on t0 (a, idate, c); -- c does not have to be in the > index > CREATE INDEX t1_1 on t1 (f, idat

Re: [sqlite] SQL CASE WHEN THEN ELSE END

2020-01-27 Thread Jose Isaias Cabrera
Keith Medcalf, on Monday, January 27, 2020 02:28 AM, wrote... > > > Do you perhaps mean: > > SELECT a.a, > a.c, > a.e, > b.g, > b.h, > b.i, > coalesce(( >SELECT 'YES' > FROM t2 > WH

Re: [sqlite] SQL CASE WHEN THEN ELSE END

2020-01-27 Thread Jose Isaias Cabrera
> says a lot about anticipated traffic volume. > > >-Original Message- > >From: sqlite-users On > >Behalf Of Jose Isaias Cabrera > >Sent: Sunday, 26 January, 2020 19:44 > >To: SQLite mailing list > >Subject: [sqlite] SQL CASE WHEN THEN ELSE END

Re: [sqlite] SQL CASE WHEN THEN ELSE END

2020-01-27 Thread Jose Isaias Cabrera
Simon Slavin, on Sunday, January 26, 2020 09:59 PM, wrote... > > On 27 Jan 2020, at 2:44am, Jose Isaias Cabrera > 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 CAS

Re: [sqlite] SQL CASE WHEN THEN ELSE END

2020-01-27 Thread Keith Medcalf
ic volume. >-Original Message- >From: sqlite-users On >Behalf Of Keith Medcalf >Sent: Monday, 27 January, 2020 00:28 >To: SQLite mailing list >Subject: Re: [sqlite] SQL CASE WHEN THEN ELSE END > > >Do you perhaps mean: > > SELECT a.a, > a.

Re: [sqlite] SQL CASE WHEN THEN ELSE END

2020-01-26 Thread Keith Medcalf
Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-Original Message- >From: sqlite-users On >Behalf Of Jose Isaias Cabrera >Sent: Sunday, 26 January, 2020 19:44 >To: SQLite mailing list >Subject: [sqlite] SQL CASE WHEN THEN ELSE END >

Re: [sqlite] SQL CASE WHEN THEN ELSE END

2020-01-26 Thread Keith Medcalf
traffic volume. >-Original Message- >From: sqlite-users On >Behalf Of Jose Isaias Cabrera >Sent: Sunday, 26 January, 2020 19:44 >To: SQLite mailing list >Subject: [sqlite] SQL CASE WHEN THEN ELSE END > > >Greetings! > >I am getting the wrong output, and I don't k

Re: [sqlite] SQL CASE WHEN THEN ELSE END

2020-01-26 Thread Jose Isaias Cabrera
Igor Tandetnik, on Sunday, January 26, 2020 09:57 PM, wrote... > > On 1/26/2020 9:44 PM, Jose Isaias Cabrera wrote: > > CASE > > ( > >SELECT WYear FROM t2 WHERE pid = a.a > > ) > > WHEN c.WYear = 2020 THEN “YES” > > ELSE “NO” END > > ) AS DIGITAL > > This shoul

Re: [sqlite] SQL CASE WHEN THEN ELSE END

2020-01-26 Thread Simon Slavin
On 27 Jan 2020, at 2:44am, Jose Isaias Cabrera 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

Re: [sqlite] SQL CASE WHEN THEN ELSE END

2020-01-26 Thread Igor Tandetnik
On 1/26/2020 9:44 PM, Jose Isaias Cabrera wrote: CASE ( SELECT WYear FROM t2 WHERE pid = a.a ) WHEN c.WYear = 2020 THEN “YES” ELSE “NO” END ) AS DIGITAL This should probably be simply case c.WYear when 2020 then 'YES' else 'NO' end or equivalently case whe

[sqlite] SQL CASE WHEN THEN ELSE END

2020-01-26 Thread Jose Isaias Cabrera
Greetings! I am getting the wrong output, and I don't know how to get it to work. Please take a look at the following (Pardon the lengthy data): create table t0 (n INTEGER PRIMARY KEY, a, b, c, d, e, idate); insert into t0 (a, b, c, d, e, idate) values ('p001', 1, 2019, 'n', 4, '2019-02-11');