See below: mysql> (SELECT avg FROM event_log_5minute_20050104 WHERE monitor_id=479139 AND monitor_server_id=1 AND timestamp >= 20050104080000 AND timestamp < 20050105080000 order by avg); +---------+ | avg | +---------+ | NULL | | NULL | | NULL | | NULL | | NULL | | 55854.1 | | 55854.1 | | 63566.8 | | 70157.6 | | 121185 | | 128803 | | 172269 | | 320097 | +---------+ 13 rows in set (0.00 sec)
mysql> (SELECT avg FROM event_log_5minute_20050104 WHERE monitor_id=479139 AND monitor_server_id=1 AND timestamp >= 20050104080000 AND timestamp < 20050105080000) order by avg; +---------+ | avg | +---------+ | NULL | | 55854.1 | | 55854.1 | | 63566.8 | | 70157.6 | | 121185 | | 128803 | | 172269 | | 320097 | +---------+ 9 rows in set (0.00 sec) mysql> As you can see, I have 13 rows that match the query, if I put the order by in the brackets it works fine. But when moved outside of them it fails. The reason I have the brackets is this is a dynamically generated query and may span tables ie: (SELECT avg FROM event_log_5minute_20050104 WHERE monitor_id=479139 AND monitor_server_id=1 AND timestamp >= 20050104080000 AND timestamp < 20050105080000) UNION ALL (SELECT avg FROM event_log_5minute_20050105 WHERE monitor_id=479139 AND monitor_server_id=1 AND timestamp >= 20050104080000 AND timestamp < 20050105080000) order by avg; Am I missing something and this is expected behavior and not a bug? I'm using 4.0.18, I haven't checked the changelogs yet, maybe its been fixed. -- John A. McCaskey Software Development Engineer Klir Technologies, Inc. [EMAIL PROTECTED] 206.902.2027 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]