岁月如灬风
2019-12-25 11:06
采纳率: 76.9%
浏览 185

oracle SQL语句问题,大神们留步,帮忙看一下。

查询语句

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时间最新的显示
这个怎么写,有大佬帮忙看一下吗。。。

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

相关推荐 更多相似问题