猫头鹰的头(提问者) 回复 CD20160914 SELECT
c.DEPARTMENT_NAME,
SUM ( a.Eat_FactMoney ) AS zhekoujine
FROM
[dbo].[EAT_DAYSALEINFO] a,
ORG_DEPARTMENT c
WHERE 1=1 AND
a.DEPARTMENT_ID= c.DEPARTMENT_ID
AND a.CHANNEL_ID= b.CHANNEL_ID
AND a.RPT_DATE BETWEEN \'${START_DATE}\' AND \'${END_DATE}\'
AND a.DEPARTMENT_ID = \'${DEPARTMENT_ID}\'
${if(len(Eat_PhaseName) == 0,\"\",\"and a.Eat_PhaseID = \'\" + Eat_PhaseName + \"\'\")}
GROUP BY
c.DEPARTMENT_NAME