SELECT CASE WHEN '${timeScale}' = '年' THEN TO_CHAR(TO_TIMESTAMP(alert.ALARM_TIME, 'YYYYMMDDHH24MISS'), 'YYYY') WHEN '${timeScale}' = '季' THEN TO_CHAR(TO_TIMESTAMP(alert.ALARM_TIME, 'YYYYMMDDHH24MISS'), 'YYYY') || 'Q' || TO_CHAR(TO_TIMESTAMP(alert.ALARM_TIME, 'YYYYMMDDHH24MISS'), 'Q') WHEN '${timeScale}' = '月' THEN TO_CHAR(TO_TIMESTAMP(alert.ALARM_TIME, 'YYYYMMDDHH24MISS'), 'YYYY-MM') WHEN '${timeScale}' = '周' THEN TO_CHAR(TO_TIMESTAMP(alert.ALARM_TIME, 'YYYYMMDDHH24MISS'), 'IYYY-IW') WHEN '${timeScale}' = '日' THEN TO_CHAR(TO_TIMESTAMP(alert.ALARM_TIME, 'YYYYMMDDHH24MISS'), 'YYYY-MM-DD') END AS time_group, alert.*FROM NED_Straight_through_alert alertWHERE TO_TIMESTAMP(alert.ALARM_TIME, 'YYYYMMDDHH24MISS') BETWEEN CASE WHEN '${timeRange}' = '自定义' THEN TO_TIMESTAMP(TO_CHAR('${startDate}', 'YYYYMMDD') || '000000', 'YYYYMMDDHH24MISS') WHEN '${timeRange}' = '本年' THEN TRUNC(SYSDATE, 'YYYY') WHEN '${timeRange}' = '本季' THEN TRUNC(SYSDATE, 'Q') WHEN '${timeRange}' = '本月' THEN TRUNC(SYSDATE, 'MM') WHEN '${timeRange}' = '本周' THEN TRUNC(SYSDATE, 'IW') WHEN '${timeRange}' = '昨日' THEN TRUNC(SYSDATE - 1) WHEN '${timeRange}' = '今日' THEN TRUNC(SYSDATE) END AND CASE WHEN '${timeRange}' = '自定义' THEN TO_TIMESTAMP(TO_CHAR('${endDate}', 'YYYYMMDD') || '235959', 'YYYYMMDDHH24MISS') WHEN '${timeRange}' = '本年' THEN ADD_MONTHS(TRUNC(SYSDATE, 'YYYY'), 12) - INTERVAL '1' SECOND WHEN '${timeRange}' = '本季' THEN ADD_MONTHS(TRUNC(SYSDATE, 'Q'), 3) - INTERVAL '1' SECOND WHEN '${timeRange}' = '本月' THEN ADD_MONTHS(TRUNC(SYSDATE, 'MM'), 1) - INTERVAL '1' SECOND WHEN '${timeRange}' = '本周' THEN TRUNC(SYSDATE, 'IW') + 7 - INTERVAL '1' SECOND WHEN '${timeRange}' = '昨日' THEN TRUNC(SYSDATE) - INTERVAL '1' SECOND WHEN '${timeRange}' = '今日' THEN TRUNC(SYSDATE) + INTERVAL '1' DAY - INTERVAL '1' SECOND END AND alert.model = '${model}' AND alert.lot = '${lot}' AND alert.linename = '${lineno}'ORDER BY time_group DESC只要是自定义的,查询的时候就没有数据,选本年,本月这些就没问题