科目     日期       金额
001     20050617     10
002     20050617     10
003     20050617     10
001     20050618     10
002     20050618     10
001     20050619     10
003     20050619     10
001     20050620     10
002     20050620     10
003     20050620     10
......  .......      ..
如何统计每个科目最新的金额?

解决方案 »

  1.   

    顺便帮助我一下:http://community.csdn.net/Expert/topic/4223/4223925.xml?temp=.4511225
      

  2.   

    select distinct 科目, first_value(金额) over(partiton by 科目 order by 日期 desc) from tbname;
      

  3.   

    select 科目,max(日期) 日期,max(金额) 金额 from tablename group by 科目
      

  4.   

    水清如果金额不是最大的怎么办呀
    select 科目,金额 from table1 t,(select 科目,max(日期) from table1 group by 科目)s
    where t.科目=s.科目 and t.日期=s.日期