Select first(a1),first(a2),first(a3),SUM(a4) from Table1 Group By a1 where rownum=1;

解决方案 »

  1.   

    Select first(a1),first(a2),first(a3),SUM(a4) from Table1 Group By a1 where rownum<2;
      

  2.   

    谢谢两位的回答,但first 这个函数只有在SQL Server 和Access中才能用,
    Oracle中没有这个函数,不知有类似的函数否?
      

  3.   

    Select a1,a2,a3,SUM(a4) from Table1 Group By a1 where rownum<2;
      

  4.   

    LGQDUCKY(飘) :
      rownum=1只能取一条, 我需要的是每个Group 后的第一条
      

  5.   

    a1关键字?
    select a.a1,a.a2,a.a3,a.summ from table1 a,
    (select a1,sum(a4) from table1 group by a1) b
     where a.a1 = b.a1
      

  6.   

    Select min(rowid),a1,a2,a3,SUM(a4) from Table1 Group By a1
      

  7.   

    select max(f_a1),max(f_a2),max(f_a3),max(s_a4) from
    (select a1,first(a1) over(partition by a1) f_a1,first(a2) over(partition by a1) f_a2,first(a3) over(partition by a1) f_a3,sum(a4) over(partition by a1 order by rownum) s_a4
    from Table1)
    group by a1
      

  8.   


    Select min(rowid),a1,a2,a3,SUM(a4) over(ORDER BY a4) from Table1 差不多是这个样子