|
楼主 |
发表于 2007-6-19 17:35:15
|
显示全部楼层
我直接把策略里的条件作为数据集sql语句的where,执行起来是可以的。整个语句如下
select A.SALESDEPT,A.FREIGHT,A.BACK,A.SMALL,A.SAMPLE,A.ADJUST,A.SALES,A.RETURN,A.INVOICE
from
(SELECT
SALESDEPT,
SUM(CASE WHEN FREIGHTTYPE='正常出货' THEN MONEYSUM ELSE 0 END) AS FREIGHT,
SUM(CASE WHEN FREIGHTTYPE='正常退货' THEN MONEYSUM ELSE 0 END) AS BACK,
SUM(CASE WHEN FREIGHTTYPE='小缸费' THEN MONEYSUM ELSE 0 END) AS SMALL,
SUM(CASE WHEN FREIGHTTYPE='打样费' THEN MONEYSUM ELSE 0 END) AS SAMPLE,
SUM(CASE WHEN FREIGHTTYPE='数量调整' THEN MONEYSUM ELSE 0 END) +
SUM(CASE WHEN FREIGHTTYPE='金额调整' THEN MONEYSUM ELSE 0 END) AS ADJUST,
SUM(MONEYSUM) AS SALES,
SUM(HAVERETURN) AS RETURN,
SUM(HAVEINVOICED) AS INVOICE
FROM
(
SELECT TM_FREIGHTSUB.PKID,TM_FREIGHTSUB.FREIGHTTYPE, TM_FREIGHTSUB.MONEYSUM, CHECKSUB.HAVERETURN, CHECKSUB.HAVEINVOICED, TM_FREIGHTMAIN.SALESDEPT,TM_FREIGHTMAIN.FREIGHTDATE
FROM TM_FREIGHTMAIN,TM_FREIGHTSUB,CHECKSUB where TM_FREIGHTSUB.UPPERID = TM_FREIGHTMAIN.PKID(+) and TM_FREIGHTSUB.PKID=CHECKSUB.FREIGHTPKID(+)
AND TM_FREIGHTMAIN.FREIGHTDATE between :BeginDate and :EndDate
)
GROUP BY SALESDEPT
) A
where A.SALESDEPT = &[Biz:\SYSTEM\ORGPARAMS.PARAMGROUP\DeptID.Param] |
|