* REPLACED ACTUAL TABLE NAMES FOR THIS EXAMPLE: SELECT a.ccompany, a.custcode, COUNT(b.req_date) as nTotal, ; SUM(b.nstorage) as nStorage, SUM(b.tow_chrg) as nTows ; FROM a; JOIN b ON b.custcode = a.custcode; WHERE b.control_no in ; (SELECT towfky FROM redeem WHERE redeem.dredeemdat>= {01/01/2014} AND redeem.dredeemdat<= {12/31/2014}) ; GROUP BY 1,2 ; into cursor temp1 readwriteNow add the ORDER and the totals go haywire
* REPLACED ACTUAL TABLE NAMES FOR THIS EXAMPLE: SELECT a.ccompany, a.custcode, COUNT(b.req_date) as nTotal, ; SUM(b.nstorage) as nStorage, SUM(b.tow_chrg) as nTows ; FROM a; JOIN b ON b.custcode = a.custcode; WHERE b.control_no in ; (SELECT towfky FROM redeem WHERE redeem.dredeemdat>= {01/01/2014} AND redeem.dredeemdat<= {12/31/2014}) ; GROUP BY 1,2 ; ORDER BY 1,2 ; into cursor temp1 readwriteTIA