SQL> select * from test2; ID ZYZ1 P1
---------- ---------- ----------
62 3
4 ryuy 5
1 1
6 zyz 11
6 zyz 2121SQL> select * from (select id,sum(p1) as p1 from test2 group by id) order by p1
; ID P1
---------- ----------
1 1
62 3
4 5
6 2132
---------- ---------- ----------
62 3
4 ryuy 5
1 1
6 zyz 11
6 zyz 2121SQL> select * from (select id,sum(p1) as p1 from test2 group by id) order by p1
; ID P1
---------- ----------
1 1
62 3
4 5
6 2132
select * from tablename [where where_clause] group by col1 order by col1