Richard,
Tuesday, August 06, 2002, 9:05:16 PM, you wrote:

RU> Using MySQL 3.2.3.51-nt

RU> I think there's something wrong with the way I'm combining the IF and MIN/MAX 
functions...

RU> I'm using aggregate functions of the form MIN( IF( condition, int, NULL ) ), and 
MAX with the same predicate, and getting MINs bigger than MAXs.

RU> Specifically, my query is:

RU>         SELECT 
RU> t_calendar.hour, 
RU> AVG( IF(t_calllog_calls.call_end - t_calllog_calls.call_start > 5, 
t_calllog_calls.call_end - t_calllog_calls.call_start,NULL) ), 
RU> MIN( IF(t_calllog_calls.call_end - t_calllog_calls.call_start > 5, 
t_calllog_calls.call_end - t_calllog_calls.call_start, NULL) ), 
RU> MAX( IF(t_calllog_calls.call_end - t_calllog_calls.call_start > 5, 
t_calllog_calls.call_end - t_calllog_calls.call_start, NULL) )
RU>         FROM 
RU> t_calllog_calls INNER JOIN t_calendar ON t_calendar.id = t_calllog_calls.time_key
RU>         WHERE 
RU> t_calendar.hour between 0 and 10 AND 
RU> t_calendar.id between 2002061600 and 2002061699 
RU>         GROUP BY 
RU> t_calendar.hour;

>From this, I get results:

RU> |hour  | AVG     | MIN | MAX|
RU> |    5 | 97.7562 | 100 | 99 |
RU> |    6 | 97.7590 | 96  | 99 |
RU> |    7 | 97.8342 | 100 | 99 |
RU> |    8 | 97.8265 | 100 | 99 |
RU> |    9 | 97.6932 | 100 | 99 |
RU> |   10 | 97.8036 | 100 | 99 |


Thanks for bug report!

If NULL is present (t_calllog_calls.call_end -
t_calllog_calls.call_start <= 5) the result_type is changed from
int to char.

It was fixed.




-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to