select jobid max(effdate||sal) from table_name group by jobid

解决方案 »

  1.   

    select jobid,effdate,sal from 
    (select jobid,effdate,sal,row_number() over (partition by jobid order by effdate desc) rk from tab)
    where rk = 1
      

  2.   

    select jobid,effdate,sal from(select t.*,row_number() over(partition by jobid order by effdate desc) rn from table_name t) where rn = 1;
      

  3.   

    select jobid, max(effdate), sal from tab_name group by jobid, sal;
      

  4.   

    select jobid, max(effdate), sal from tab_name group by jobid, sal;
    这个好像不可以把,会把所有的记录都显示出来的select jobid,effdate,sal from
    (
    select t.*,row_number() over(partition by jobid order by effdate desc) seq from table_name t

    where seq = 1;
      

  5.   

    select jobid, max(effdate), sal from tab_name group by jobid, sal;
    这个语句可以,我测试过了
      

  6.   

    不好意思,没有经过认真的思考,那个语句是不好用的。SQL> select * from ddd;      COLA COLB                 COLC
    ---------- -------------- ----------
           111 01-1月 -05           1000
           111 01-5月 -05           2000
           222 01-2月 -05           1300
           222 03-5月 -05           2300已用时间:  00: 00: 00.00
    SQL> select cola,colb,colc from(select t.*,row_number() over(partition by cola order by colb desc) rn from ddd t) where rn =
     1;      COLA COLB                 COLC
    ---------- -------------- ----------
           111 01-5月 -05           2000
           222 03-5月 -05           2300已用时间:  00: 00: 00.01
      

  7.   

    如果只是时间最近:select jobid, max(effdate), sal from tab_name group by jobid;
      

  8.   

    学到了。
    看来我的sql还是很烂啊!
    大虾们能不能推荐一本好的学习sql的书啊?
    最好能在网上免费下载的。
    多谢啊!
      

  9.   

    在哪里可以找到有关Oracle分析函数用法的资料
      

  10.   

    你可以下载oracle9i的联机文档,里面的东西应该是最全的了。
      

  11.   

    select jobid,max(effdate) effdate,(select sal from tab where jobid=t.jobid and effdate=t.effdate) sal from tab t group by jobid;