怎么获取上次失业信息(where条件里的max函数)

来源:互联网 发布:统计直报网乱报数据 编辑:程序博客网 时间:2024/04/27 21:19

选择拥有最值的数据元所在的该行记录。


类似语句:

选择生物最高成绩的学生姓名

选择个人顺序号里最大的失业资料顺序号(即为上次失业信息)



--获取上次失业信息,根据pi_grsxh查询yz_shiyeryzl,且失业资料顺序号不为传入的pi_ryzlsxh的最近一次失业的人员资料顺序号和经办时间

    begin
      select shiyezlsxh,jbrq,SUBSTR(shiyedjrq,1,6) into v_shiyezlsxh,v_jbrq,v_scsyny
      from yz_shiyeryzl
      where grsxh = pi_grsxh
        and shiyezlsxh = (SELECT MAX(shiyezlsxh) FROM yz_shiyeryzl WHERE grsxh=pi_grsxh and shiyezlsxh <> nvl(pi_ryzlsxh,999999999999))
        --and shiyezlsxh <> nvl(pi_ryzlsxh,999999999999)
        and zlztbz <> '99';
    exception
      when no_data_found then
        v_scsyny:='190001';  --
        v_schdsj:=0;
        v_schdsj_d:=to_date('190001','yyyymm');

    end;



个人顺序号在个人基本资料ys_grjbzl里

资料顺序号在失业人员资料YZ_SHIYERYZL里

0 0
原创粉丝点击