时间:2021-07-01 10:21:17 帮助过:606人阅读
WITH t1 AS ( SELECT YLPLID,MAX(SBSJ) SBSJ FROM YLPLCG where YLPLID in(select YLPLID from CYQYCPYLPLGX where CPID=‘659DE0BC42544B74B660E37E665F437C‘) group by YLPLID ) SELECT t.YLPLMC,case when t.YLPLLX =1 then ‘原料‘ when t.YLPLLX = 2 then ‘配料‘ end YLPLLX , t.GYSID,t.GYSMC,t.JYHGBGDTPID FROM YLPLCG t INNER JOIN t1 ON t.YLPLID = t1.YLPLID AND to_char(t.SBSJ, ‘yyyy-MM-dd HH24:mm:ss‘)= to_char(t1.SBSJ, ‘yyyy-MM-dd HH24:mm:ss‘)
取重复记录中时间最新的一条记录Oracle sql语句
标签:where and ora nbsp rom 语句 时间 记录 inner