SELECT
POINT_ID,
VEHICLE_TYPE AS EX_VEHICLE_TYPE,
org.SHORTNAME AS orgname,
org.ID,
org.SUPERIOR_ORGAN,
organ.SHORTNAME AS bootname
${if(statisticsType==4,"
,SHIFT_NO
,SUM(PAY_FEE)/100 PAY_FEE_SUM
,COUNT(*) TRAFFIC_SUM
FROM T_STATION_GREENPASS_WASTE t,
T_COMM_ORGAN org,
T_COMM_ORGAN organ
WHERE 1=1
AND organ.ID=org.SUPERIOR_ORGAN
AND t.POINT_ID=org.ID
and t.SHIFT_NO ='"+shift+"'
and t.EX_TIME >= to_date('"+yearMonthDay+" 00:00:00','yyyy-mm-dd hh24:mi:ss')
and t.EX_TIME <= to_date('"+yearMonthDay+" 23:59:59','yyyy-mm-dd hh24:mi:ss')
GROUP BY POINT_ID,
VEHICLE_TYPE,
SHIFT_NO,
org.SHORTNAME ,
org.ID,
org.SUPERIOR_ORGAN,
organ.SHORTNAME
ORDER BY POINT_ID,VEHICLE_TYPE ASC","")}
==========
-- 这是我用上面的参数执行出来的sql脚本,你要是说再不行,我也不知道说什么了= =#
==========
SELECT
POINT_ID,
VEHICLE_TYPE AS EX_VEHICLE_TYPE,
org.SHORTNAME AS orgname,
org.ID,
org.SUPERIOR_ORGAN,
organ.SHORTNAME AS bootname
,SHIFT_NO
,SUM(PAY_FEE)/100 PAY_FEE_SUM
,COUNT(*) TRAFFIC_SUM
FROM T_STATION_GREENPASS_WASTE t,
T_COMM_ORGAN org,
T_COMM_ORGAN organ
WHERE 1=1
AND organ.ID=org.SUPERIOR_ORGAN
AND t.POINT_ID=org.ID
and t.SHIFT_NO ='qqq'
and t.EX_TIME >= to_date('qqq 00:00:00','yyyy-mm-dd hh24:mi:ss')
and t.EX_TIME <= to_date('qqq 23:59:59','yyyy-mm-dd hh24:mi:ss')
GROUP BYPOINT_ID,
VEHICLE_TYPE,
SHIFT_NO,
org.SHORTNAME ,
org.ID,
org.SUPERIOR_ORGAN,
organ.SHORTNAME
ORDER BY POINT_ID,VEHICLE_TYPE ASC
射手座、(提问者)statisticsType分为1~4,分别写在$if语句里,现在想知道,statisticsType=4的时候,怎么在if语句里面在加入一个参数shift ?,没有加shiftNo这一行SQL都可以执行,加上这个参数就不行了
--按年
${if(statisticsType==0,\"
,SUM(PAY_FEE)/100 PAY_FEE_SUM
,COUNT(*) TRAFFIC_SUM
FROM T_STATION_GREENPASS_WASTE t,
T_COMM_ORGAN org,
T_COMM_ORGAN organ
WHERE 1=1
AND organ.ID=org.SUPERIOR_ORGAN
AND t.POINT_ID=org.ID
and t.EX_TIME >= to_date(\'\"+year+\"-01-01\"+\"\',\'yyyy-mm-dd\')
and t.EX_TIME < add_months(to_date(\'\"+year+\"-01-01\"+\"\',\'yyyy-MM-dd\'),12)
GROUP BY POINT_ID,
VEHICLE_TYPE,
org.SHORTNAME ,
org.ID,
org.SUPERIOR_ORGAN,
organ.SHORTNAME
ORDER BY POINT_ID,VEHICLE_TYPE ASC\",\"\")}
--按月
${if(statisticsType==1,\"
,SUM(PAY_FEE)/100 PAY_FEE_SUM
,COUNT(*) TRAFFIC_SUM
FROM T_STATION_GREENPASS_WASTE t,
T_COMM_ORGAN org,
T_COMM_ORGAN organ
WHERE 1=1
AND organ.ID=org.SUPERIOR_ORGAN
AND t.POINT_ID=org.ID
and t.EX_TIME >= to_date(\'\"+yearMonth+\"-01\"+\"\',\'yyyy-mm-dd\')
and t.EX_TIME < add_months(to_date(\'\"+yearMonth+\"-01\"+\"\',\'yyyy-MM-dd\'),1)
GROUP BY POINT_ID,
VEHICLE_TYPE,
org.SHORTNAME ,
org.ID,
org.SUPERIOR_ORGAN,
organ.SHORTNAME
ORDER BY POINT_ID,VEHICLE_TYPE ASC\",\"\")}