SELECT d.LOTID 批次编码, d.FORMERQTY 批次原数量, sum(d.LASTQTY) 批次现数量, d.ISRECIPE 型号编码, d.FGCODE 型号规格, d.FGKIND 材质, d.FGCODEVERSION 成品型号, d.EVENTUSER 操作人, d.WORKORDER 生产订单, d.WORKSHOPNAME 车间名称, d.LINE 产线编号, d.LINENAME 产线名称, d.MACHINECODE 设备编号, d.MACHINENAME 设备名称, d.FIXCODE 治具编号, d.FIXNAME 治具名称, d.BACKUP1 模号, u.USERNAME 操作人, CASE WHEN to_char(d.EVENTTIME,'hh24')>=8 then to_char(d.EVENTTIME,'yyyy-mm-dd') WHEN to_char(d.EVENTTIME,'hh24')<8 then to_char(d.EVENTTIME-1,'yyyy-mm-dd') end 操作时间, CASE WHEN to_char(d.EVENTTIME,'hh24')>=8 and to_char(d.EVENTTIME,'hh24')<20 then '白班' WHEN to_char(d.EVENTTIME,'hh24')>=20 or to_char(d.EVENTTIME,'hh24')<8 then '晚班' end 班次 FROM DGB_PLOTHISTORY d JOIN USERINFO u on d.EVENTUSER=u.USERID where 1=1 AND TO_CHAR(d.EVENTTIME,'YYYY-MM-DD')>= ('2021-10-13') AND TO_CHAR(d.EVENTTIME,'YYYY-MM-DD')<= ('2021-10-13') group by d.LOTID,d.FORMERQTY,d.LASTQTY,d.ISRECIPE,d.FGCODE,d.FGKIND,d.FGCODEVERSION,d.EVENTUSER,d.WORKORDER,d.WORKSHOPNAME,d.LINE,d.LINENAME,d.MACHINECODE,d.MACHINENAME,d.FIXCODE,d.FIXNAME,d.BACKUP1,u.USERNAME, CASE WHEN to_char(d.EVENTTIME,'hh24')>=8 then to_char(d.EVENTTIME,'yyyy-mm-dd') WHEN to_char(d.EVENTTIME,'hh24')<8 then to_char(d.EVENTTIME-1,'yyyy-mm-dd') end , CASE WHEN to_char(d.EVENTTIME,'hh24')>=8 and to_char(d.EVENTTIME,'hh24')<20 then '白班' WHEN to_char(d.EVENTTIME,'hh24')>=20 or to_char(d.EVENTTIME,'hh24')<8 then '晚班' end order by d.EVENTTIME desc oracle的日期条件变成年月日时分秒的 要怎么写语句呢 |