Re: [sqlite] SQL question, move union to second column

2019-03-13 Thread Bart Smissaert
Ah, yes, thanks. RBS On Thu, Mar 14, 2019 at 12:55 AM Igor Tandetnik wrote: > On 3/13/2019 8:32 PM, Bart Smissaert wrote: > > Sorry, ignore that, can see now that all is a reserved word. > > You can enclose it in double quotes, as in "All", if you really want it. > -- > Igor Tandetnik > > >

Re: [sqlite] SQL question, move union to second column

2019-03-13 Thread Igor Tandetnik
On 3/13/2019 8:32 PM, Bart Smissaert wrote: Sorry, ignore that, can see now that all is a reserved word. You can enclose it in double quotes, as in "All", if you really want it. -- Igor Tandetnik ___ sqlite-users mailing list

Re: [sqlite] SQL question, move union to second column

2019-03-13 Thread Bart Smissaert
Sorry, ignore that, can see now that all is a reserved word. RBS On Thu, Mar 14, 2019 at 12:30 AM Bart Smissaert wrote: > Thanks; this works fine: > > select PLACE, > sum(ID not in (select ID from ATTENDED)), > count(ID) > from PERSONS group by PLACE > > But if I add the aliases I

Re: [sqlite] SQL question, move union to second column

2019-03-13 Thread Bart Smissaert
Thanks; this works fine: select PLACE, sum(ID not in (select ID from ATTENDED)), count(ID) from PERSONS group by PLACE But if I add the aliases I get: near "All": syntax error Result of sqlite3_prepare16_v3: 1 select PLACE, sum(ID not in (select ID from ATTENDED)) Not_Attended,

Re: [sqlite] SQL question, move union to second column

2019-03-13 Thread Igor Tandetnik
On 3/13/2019 8:08 PM, Bart Smissaert wrote: But I would like the result to be in 3 columns, so result in this case would be: Place Not_Attended All --- A 3 7 B 2 3 Something like this (not tested): select

[sqlite] SQL question, move union to second column

2019-03-13 Thread Bart Smissaert
Have 2 tables: PERSONS: CREATE TABLE [PERSONS]([ID] INTEGER PRIMARY KEY, [Place] TEXT) ATTENDED: CREATE TABLE [ATTENDED]([ID] INTEGER) Sample date like this: PERSONS: ID Place --- 1 A 2 A 3 B 4 A 5 A 6 A 7 B 8 B 9 A 10 A ATTENDED: ID - 1 5 6 1 1 8 9 5 1 5 8 1 6 8 9 9 1 5 6 1