mysql Ver 14.12 Distrib 5.0.22, for pc-linux-gnu (i486) using readline 5.1
mysql> select avg(keyval) from nodes where keyval <= 0.6158;
+------------------+
| avg(keyval) |
+------------------+
| 0.38034999370575 |
+------------------+
1 row in set (0.00 sec)
mysql> select max(keyval) from nodes where keyval <= 0.6158;
Empty set (0.00 sec)
I hope the behavior for the second query is not correct.
Is there a workaround? Here is the data:
----------------------------------------------------------------
DROP TABLE IF EXISTS `nodes`;
CREATE TABLE `nodes` (
`id` int(11) NOT NULL,
`keyval` float default NULL,
`child_id` int(11) default NULL,
`child_accum` double default NULL,
UNIQUE KEY `keyval` (`keyval`),
UNIQUE KEY `child_id` (`child_id`),
UNIQUE KEY `id_2` (`id`,`keyval`),
KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
LOCK TABLES `nodes` WRITE;
INSERT INTO `nodes` VALUES
(3,0.3762,NULL,NULL),(3,0.3845,NULL,NULL),(11,0.7941,NULL,NULL),(2,0.6158,NULL,NULL);
UNLOCK TABLES;
----------------------------------------------------------------
Frederik Eaton
--
http://ofb.net/~frederik/