Hi, > It looks like a bug. Do you agree?
No. As I wrote, if you use an alias that has the same name as a column name, then the column name is used. I suggest not to use an alias that has the same name as a column name. Regards, Thomas On Tue, Aug 25, 2015 at 9:49 AM, Taras Fedkiv <[email protected] <javascript:_e(%7B%7D,'cvml','[email protected]');>> wrote: > Thomas, > Thank you for a quick reply. > > But h2 behaviour with aliases in HAVING is not consistent. Please take a > look at the following example: > > 1) prepare data > *CREATE MEMORY TABLE IF NOT EXISTS TABLE_123(account_id BIGINT, time > BIGINT) NOT PERSISTENT* > *INSERT INTO TABLE_123 (account_id,time) VALUES (20,3)* > *INSERT INTO TABLE_123 (account_id,time) VALUES (20,4)* > > *2) run query* > *SELECT account_id, COUNT(time) as time FROM TABLE_123 GROUP BY account_id > HAVING time=2 * > throws an exception > *Caused by: org.h2.jdbc.JdbcSQLException: Column """time""" must be in the > GROUP BY list; SQL statement:* > *SELECT account_id, COUNT(time) as time FROM TABLE_123 GROUP BY account_id > HAVING time=3 [90016-187]* > > *It looks like a bug. Do you agree?* > > *Thank you,* > *Taras* > > > The information in this message may be confidential. It is intended > solely for > the addressee(s). If you are not the intended recipient, any disclosure, > copying or distribution of the message, or any action or omission taken by > you > in reliance on it, is prohibited and may be unlawful. Please immediately > contact the sender if you have received this message in error. > > -- > You received this message because you are subscribed to the Google Groups > "H2 Database" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <javascript:_e(%7B%7D,'cvml','h2-database%[email protected]');> > . > To post to this group, send email to [email protected] > <javascript:_e(%7B%7D,'cvml','[email protected]');>. > Visit this group at http://groups.google.com/group/h2-database. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/d/optout.
