查询语句
with res as
(select t.id,
(select codename from tb_tpost_code where id = r.mpostid) mpostname,
(select codename from tb_tpost_code where id = r.spostid) spostname,
(select p.unitname from PXGL_UNIT p where p.unitid = t.unitid) unitname,
t.username,
to_char(t.maintime, 'yyyy') maintime,
t.scoredate,
t.score srscore,
t.idcard,
t.flowsta,
r.reachscore,
s.itemname,
s.score perscore,
t.yitemid,
t.noexamsign,
t.estatime
from TB_TPOST_SKILLRESULT t,
TB_TPOST_SKILLITEM s,
TB_TPOST_SKILLSTANDAR r
where s.standarid = r.id
and t.yitemid = s.id
and s.flowsta = 99
and t.unitid = 163701
and ((t.noexamsign = 1 and to_char(t.estatime, 'yyyy') = 2019) or
to_char(scoredate, 'yyyy') = 2019)
and r.mpostid = 39
and r.capgrade = 1)
现要在现代码加上筛选:
条件:1.如果b.yitemid(项目ID)相同,t.idcard(同一个人)相同情况下,
t.noexamsign的值为1并且t.flowsta为99, t.estatime时间最新的显示
2.t.noexamsign不为1,t.estatime时间最新的显示
这个怎么写,有大佬帮忙看一下吗。。。