> > What's going on with the MAX() function?  Why did it return NULL
> > in the first query above.  There were no adding/deleting data between
> > the above queries and yet MySQL didn't pull the MAX from the table
> > until I added the "AND assets IS NOT NULL" to the query.  And yet
> > after I ran that query, attempting to run the first query yields the proper
> > results.
> > Is this a bug with MySQL?
> I wasn't able to repeat it on my test table. Could you provide a test case? 

Here is what our table looks like:

-- MySQL dump 9.07
--
-- Host: localhost    Database: eazypro
---------------------------------------------------------
-- Server version 4.0.12-log

--
-- Table structure for table 'do_deductibles'
--

CREATE TABLE do_deductibles (
  currency varchar(10) NOT NULL default '',
  assets int(20) NOT NULL default '0',
  deductible int(10) NOT NULL default '0',
  do_deductibles_id int(5) NOT NULL auto_increment,
  PRIMARY KEY  (do_deductibles_id),
  UNIQUE KEY do_deductibles_idx (currency,assets)
) TYPE=ISAM PACK_KEYS=1;

--
-- Dumping data for table 'do_deductibles'
--

INSERT INTO do_deductibles VALUES ('USD',2500000,10000,1);
INSERT INTO do_deductibles VALUES ('USD',5000000,15000,2);
INSERT INTO do_deductibles VALUES ('USD',7500000,20000,3);
INSERT INTO do_deductibles VALUES ('USD',10000000,25000,4);
INSERT INTO do_deductibles VALUES ('CAD',2500000,10000,5);
INSERT INTO do_deductibles VALUES ('CAD',5000000,15000,6);
INSERT INTO do_deductibles VALUES ('CAD',7500000,20000,7);
INSERT INTO do_deductibles VALUES ('CAD',10000000,25000,8);

SELECT MAX(assets) as assets FROM do_deductibles WHERE currency = 'usd';
SELECT MAX(assets) as assets FROM do_deductibles WHERE currency = 'usd' AND assets IS 
NOT NULL;
SELECT MAX(assets) as assets FROM do_deductibles WHERE currency = 'usd';


First SELECT query above returns NULL, the second returns the proper
value as does the third.

Chris
mysql,query,blah


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to