>Created new tables from scratch, entered 100 records. Indexed. Still same problem. The where in the subselect is returning dredeemdat fields that it should not.
>
>>>redeem.dredeemdat is never null, although it can be empty.
>>>
>>There is absolutely no reason then for the SELECTs behave differently. I would check all involved tables and indexes for corruption.
Try:
SELECT;
Cur1.ccompany,;
Cur1.custcode,;
COUNT(Cur1.req_date) AS nTotal,;
SUM(Cur1.nstorage) AS nstorage,;
SUM(Cur1.tow_chrg) AS nTows;
FROM (;
SELECT;
Cur1_1.ccompany,;
Cur1_1.custcode,;
Cur1_2.req_date,;
Cur1_2.nstorage,;
Cur1_2.tow_chrg;
FROM a AS Cur1_1;
INNER JOIN b AS Cur1_2;
ON Cur1_2.custcode=Cur1_1.custcode;
WHERE Cur1_1.control_no IN (;
SELECT;
Cur1__1.towfky FROM redeem AS Cur1__1;
WHERE Cur1__1.dredeemdat b>= {01/01/2014} AND Cur1__1.dredeemdat<= {12/31/2014};
);
) AS Cur1;
INTO CURSOR temp1 READWRITE;
GROUP BY 1,2;
ORDER BY 1,2
not tested, no data
It first sorts out the records and then group/order. Your version do the other way around
Lutz
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord
Weeks of programming can save you hours of planning.
OffThere is no place like [::1]