arrgg, sorry i made a mistake and my precedent mail was sent before i finished wrting it :-{,
the query is: INSERT INTO `TBL_COUNT_EXCLUDE` SELECT MAIN.id, SUM(IF(EX.excl_date BETWEEN MAIN.start_date AND MAIN.end_date, 1, 0)) AS excl_count FROM TBL_MAIN_DATE AS MAIN, TBL_EXCLUDE_DATE AS EX GROUP BY id and after that i substract the number of days between start_date and end_date for each row, minus excl_count. i dont think this is very efficient, and it takes a long time to compute on millions of rows, so any advice will be greatly appreciated. here's some info on the data i manipulate: - there's can't be more than 3 months between start_date and end_date - start_date and end_date can span on two consecutives year, i will have some cases with start_date : 2003-12-10 and end_date : 2004-02-10) ___________________________________________________________ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français ! Yahoo! Mail : http://fr.mail.yahoo.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]