表数据
日期          序号   金额
2006-01-01    1      100
2006-01-01    2      200
2006-01-01    3      500
2006-01-05    4      800
2006-01-05    5      600
2006-01-10    6      1000
2006-01-10    7      1200
...............现在需要查询上面的数据:按每天当中最大的序号数据并插入到临时表中
得到的数据为:
日期          序号   金额
2006-01-01    3      500
2006-01-05    5      600
2006-01-10    7      1200
...............

解决方案 »

  1.   

    select 日期, max(序号)over(partition by 日期,order by 序号),金额
    from tab
      

  2.   

    insert into temptab values (select distinct (日期),max(序号),金额 from tab group by 日期)
      

  3.   

    to Eric_1999(╙@^@╜) 这条语句有问题,是下面这样吗?
    select 日期,max(序号) over (partition by 日期,order by 序号),金额 from table 提示表达式有错