RE: HAVING behaviour

2003-03-09 Thread Uttam
t [mailto:[EMAIL PROTECTED] Sent: Saturday, March 08, 2003 20:40 To: MySQL List Subject: Re: HAVING behaviour Gabriel TATARANU wrote: >I had some private e-mail suggesting that MAX functions should apply to >the full table - as it is the maximum value of the field- > That is the case. Witho

Re: HAVING behaviour

2003-03-09 Thread Gabriel TATARANU
Hi, > No, not with mine :) Well , you have the wrong data. Let me post the whole thing to let people what I'm talking about. mysql> select * from tt; +--+--+ | f1 | f2 | +--+--+ |1 |1 | |1 |2 | |2 |3 | |1 |4 | +--+-

Re: HAVING behaviour

2003-03-09 Thread Sergei Golubchik
Hi! On Mar 08, Gabriel TATARANU wrote: > > > > Then, when you use group functions without explicit GROUP BY it's the > > same as GROUP BY const - that is, group functions are applied to the > > whole table (or, rather, sub-table after the WHERE). > > Ok, so we're deducting here that WHERE

Re: HAVING behaviour

2003-03-08 Thread Gabriel TATARANU
> > >Description: > > HAVING in SELECT is evaluated before WHERE. This is not the > > correct behaviour as HAVING should deal with the remainder of the WHERE > > selection (according to manual) > > I cannot understand how the following can show that "HAVING in SELECT is > evaluated before WH

Re: HAVING behaviour

2003-03-08 Thread Sergei Golubchik
Hi! On Mar 07, [EMAIL PROTECTED] wrote: > >Description: > HAVING in SELECT is evaluated before WHERE. This is not the > correct behaviour as HAVING should deal with the remainder of the WHERE > selection (according to manual) I cannot understand how the following can show that "HAVING in

Re: HAVING behaviour

2003-03-08 Thread Gabriel TATARANU
> That is the case. Without a GROUP BY, max() is supposed to apply to the > entire > table. Not true. Use of MAX in WHERE clause will show that MAX is applied to filtered data set. To use my example data set: mysql> select f2 from tt where f1=2; +--+ | f2 | +--+ |3 | +--+ 1 ro

Re: HAVING behaviour

2003-03-08 Thread Bruce Feist
Gabriel TATARANU wrote: I had some private e-mail suggesting that MAX functions should apply to the full table - as it is the maximum value of the field- That is the case. Without a GROUP BY, max() is supposed to apply to the entire table. and this is why HAVING clause behaved in that manner.

RE: HAVING behaviour

2003-03-07 Thread Uttam
ROUP BY or group functions (COUNT(), MIN()...)." regds, -Original Message- From: Gabriel Tataranu [mailto:[EMAIL PROTECTED] Sent: Friday, March 07, 2003 20:50 To: [EMAIL PROTECTED] Subject: Re: HAVING behaviour Hi, this is NOT correct behavior. Where clause returns (1,1) and (1

Re: Re: HAVING behaviour

2003-03-07 Thread Gabriel TATARANU
Hi, I had some private e-mail suggesting that MAX functions should apply to the full table - as it is the maximum value of the field- and this is why HAVING clause behaved in that manner. I'm sure this is not the case since MAX does obey (as it should) WHERE clause in the query. To

Re: HAVING behaviour

2003-03-07 Thread Gabriel Tataranu
Hi, > Your whole query is malformed. You have an aggregate function in the > having. It's absolutely legal query. In fact I don't get any error messages that say otherwise. I'm not SQL guru but I haven't heard that agregate functions have to be excuded from HAVING clause. To qu

Re: HAVING behaviour

2003-03-07 Thread gerald_clark
Your whole query is malformed. You have an aggregate function in the having. try: select f1,max(f2) from tt where f1=1 group by f1; Gabriel Tataranu wrote: Hi, this is NOT correct behavior. Where clause returns (1,1) and (1,2). The HAVING clause should be applied to what WHERE has sele

Re: HAVING behaviour

2003-03-07 Thread Gabriel Tataranu
Hi, this is NOT correct behavior. Where clause returns (1,1) and (1,2). The HAVING clause should be applied to what WHERE has selected and choose the (1,2) record. A quote from the manual "It (HAVING) is applied last, just before items are sent to the client, with no optimisation

Re: HAVING behaviour

2003-03-07 Thread gerald_clark
This is correct. WHERE clause returns (1,1) HAVING eliminates all records not HAVING f2=3. [EMAIL PROTECTED] wrote: Description: HAVING in SELECT is evaluated before WHERE. This is not the correct behaviour as HAVING should deal with the remainder of the WHERE selection (according to manua