如何用SQL进行统计,请赐教!
SELECT DISTINCT 物品名称 FROM huowu INTO CURSOR WLB CSQL=[SELECT 单位] SCAN CSQL=CSQL+",CAST(SUM(IIF(ALLTRIM(物品名称)=='" + ALLTRIM(物品名称)+"',金额,0)) AS N(6)) AS " + ALLTRIM(物品名称) + IIF(RECNO() < RECCOUNT(),""," FROM huowu GROUP BY 1 INTO CURSOR hz") ENDSCAN MESSAGEBOX(CSQL,64,[生成代码提示]) EXECSCRIPT(CSQL) BROWSE
[此贴子已经被作者于2022-10-18 01:44编辑过]