Just add rownum as your column in the subquery ..e.g.SQL> select * 2 from tablename tt;DEPT SALARY ---- ---------- aa 5000 bb 3000 bb 2000 cc 8000 cc 7000 cc 60006 rows selected SQL> select zz.*, 2 rownum 3 from ( 4 select dept, 5 sum(salary) as all_salarys 6 from tablename tt 7 group by dept 8 )zz;DEPT ALL_SALARYS ROWNUM ---- ----------- ---------- aa 5000 1 bb 5000 2 cc 21000 3
就是group byGroupID f1 f2 1 a 100 1 a 110 2 b 150 2 b 200
Just add rownum as your column in the subquery ..e.g.SQL> select *
2 from tablename tt;DEPT SALARY
---- ----------
aa 5000
bb 3000
bb 2000
cc 8000
cc 7000
cc 60006 rows selected
SQL> select zz.*,
2 rownum
3 from (
4 select dept,
5 sum(salary) as all_salarys
6 from tablename tt
7 group by dept
8 )zz;DEPT ALL_SALARYS ROWNUM
---- ----------- ----------
aa 5000 1
bb 5000 2
cc 21000 3
1 a 100
1 a 110
2 b 150
2 b 200