Re: [sqlite] New column in select will not mask column of the same name in having clause and sqlite won't warn

2015-01-09 Thread James K. Lowden
On Thu, 8 Jan 2015 08:42:25 + Hick Gunter wrote: > It is legal and well defined in SQLite. See the explain output below. > This is because of the well-documented feature of SQLite that columns > that are neither GROUPED BY nor aggregated will have a defined value. OK,

Re: [sqlite] New column in select will not mask column of the same name in having clause and sqlite won't warn

2015-01-08 Thread Hick Gunter
It is legal and well defined in SQLite. See the explain output below. This is because of the well-documented feature of SQLite that columns that are neither GROUPED BY nor aggregated will have a defined value. First off, it is legal and perfectly normal to test for expressions containing

Re: [sqlite] New column in select will not mask column of the same name in having clause and sqlite won't warn

2015-01-07 Thread James K. Lowden
On Mon, 5 Jan 2015 06:39:42 + Hick Gunter wrote: > This is completely legal and well defined. > > HAVING is applied to the RESULT set of a SELECT. I beg to differ. It's both invalid SQL and (therefore) undefined. Furthermore, it's illogical. Consider: create

Re: [sqlite] New column in select will not mask column of the same name in having clause and sqlite won't warn

2015-01-04 Thread Dan Kennedy
On 01/05/2015 02:52 PM, Dan Kennedy wrote: On 01/05/2015 01:39 PM, Hick Gunter wrote: This is completely legal and well defined. HAVING is applied to the RESULT set of a SELECT. The select asks to count the "distinct kontrola" in each group of kvadrat and datum, the HAVING clause specifies

Re: [sqlite] New column in select will not mask column of the same name in having clause and sqlite won't warn

2015-01-04 Thread Dan Kennedy
On 01/05/2015 01:39 PM, Hick Gunter wrote: This is completely legal and well defined. HAVING is applied to the RESULT set of a SELECT. The select asks to count the "distinct kontrola" in each group of kvadrat and datum, the HAVING clause specifies returning only those records with pocet > 1.

Re: [sqlite] New column in select will not mask column of the same name in having clause and sqlite won't warn

2015-01-04 Thread Hick Gunter
This is completely legal and well defined. HAVING is applied to the RESULT set of a SELECT. The select asks to count the "distinct kontrola" in each group of kvadrat and datum, the HAVING clause specifies returning only those records with pocet > 1. If there were no pocet column in table b,

Re: [sqlite] New column in select will not mask column of the same name in having clause and sqlite won't warn

2015-01-02 Thread James K. Lowden
On Sun, 28 Dec 2014 17:46:08 +0100 Tomas Telensky wrote: > select kvadrat, datum, count(distinct kontrola) as pocet > from b > group by kvadrat, datum > having pocet > 1 > > The problem was that pocet was actually a column in table b and I > didn't notice, and the

[sqlite] New column in select will not mask column of the same name in having clause and sqlite won't warn

2014-12-29 Thread Tomas Telensky
Hi, here is a bug report as posted here: http://stackoverflow.com/q/27678468/684229 I got this query in sqlite select kvadrat, datum, count(distinct kontrola) as pocet from b group by kvadrat, datum having pocet > 1 The problem was that pocet was actually a column in table b and I didn't