Ok Okd Pedant, I code it using INTO OUTFILE 'f:/result.xls' in your example, file couldnt be create....

anything wrong here...
DROP TEMPORARY TABLE IF EXISTS top_bugnotes;
CREATE TEMPORARY TABLE top_bugnotes (
bug_id INT,
max_text_id INT );
INSERT INTO top_bugnotes( bug_id, max_text_id )
SELECT bug_id, MAX(bugnote_text_id ) FROM bugnote_table
GROUP BY bug_id;
SELECT B.id, BNT.note AS 'Solution', CFS.value AS 'State'
INTO OUTFILE 'f:/result.xls'
FROM bug_table AS B,
bugnote_table AS BN,
top_bugnotes AS TB,
bugnote_text_table AS BNT,
custom_field_string_table AS CFS
WHERE BN.bug_id = B.id
AND ( TB.bug_id = BN.bug_id AND TB.max_text_id = BN.bugnote_text_id)
AND BNT.id = BN.bugnote_text_id
AND ( CFS.bug_id = B.id AND CFS.field_id = 5 AND CFS.value = 'KL' )
AND ( B.date_submitted > '2010-08-01' AND B.date_submitted < '2010-09-01' )DROP TEMPORARY TABLE IF EXISTS top_bugnotes;
CREATE TEMPORARY TABLE top_bugnotes (
bug_id INT,
max_text_id INT );
INSERT INTO top_bugnotes( bug_id, max_text_id )
SELECT bug_id, MAX(bugnote_text_id ) FROM bugnote_table
GROUP BY bug_id;
SELECT B.id, BNT.note AS 'Solution', CFS.value AS 'State'
FROM bug_table AS B,
bugnote_table AS BN,
top_bugnotes AS TB,
bugnote_text_table AS BNT,
custom_field_string_table AS CFS
WHERE BN.bug_id = B.id
AND ( TB.bug_id = BN.bug_id AND TB.max_text_id = BN.bugnote_text_id)
AND BNT.id = BN.bugnote_text_id
AND ( CFS.bug_id = B.id AND CFS.field_id = 5 AND CFS.value = 'KL' )
AND ( B.date_submitted > '2010-08-01' AND B.date_submitted < '2010-09-01' )