Re: [sqlite] Referencing a column alias (subquery) as function parameter

2016-06-20 Thread R Smith
Just a fix - the last example had a mistake in and should read: Option 2 (CTE): WITH Q (c1, c2, cd, ac) AS ( SELECT c1, c2, CurrentDate, (CASE ActiveCol WHEN 0 THEN c3 ELSE c4 END) FROM ... ) SELECT c1, c2, cd, ac, MyFn(c1,ac,cd) AS xc1, MyFn(c2,ac,cd) AS xc2

Re: [sqlite] Referencing a column alias (subquery) as function parameter

2016-06-20 Thread R Smith
On 2016/06/20 6:21 PM, Bernard Ertl wrote: Is it possible to do something like this: SELECT c1, c2, CurrentDate, (CASE ActiveCol WHEN 0 THEN c3 ELSE c4 END) AS ac, MyFn(c1,ac,CurrentDate) AS xc1, MyFn(c2,ac,CurrentDate) AS xc2 FROM ... where c1, c2, CurrentDate, ActiveCol, c3, c4 are

Re: [sqlite] Referencing a column alias (subquery) as function parameter

2016-06-20 Thread Scott Robison
On Mon, Jun 20, 2016 at 10:21 AM, Bernard Ertl wrote: > Is it possible to do something like this: > > SELECT c1, c2, CurrentDate, (CASE ActiveCol WHEN 0 THEN c3 ELSE c4 END) AS > ac, > MyFn(c1,ac,CurrentDate) AS xc1, MyFn(c2,ac,CurrentDate) AS xc2 FROM > ... >

[sqlite] Referencing a column alias (subquery) as function parameter

2016-06-20 Thread Bernard Ertl
Is it possible to do something like this: SELECT c1, c2, CurrentDate, (CASE ActiveCol WHEN 0 THEN c3 ELSE c4 END) AS ac, MyFn(c1,ac,CurrentDate) AS xc1, MyFn(c2,ac,CurrentDate) AS xc2 FROM ... where c1, c2, CurrentDate, ActiveCol, c3, c4 are all columns in the table(s) referenced in the