我需要最后显示表的类似值行,而表的其余行必须按升序排列......
代表:
Name salary
---------------------
a 100
b 200
c 300
c 400
c 600
d 200
e 500
我需要输出为,
Name salary
-----------------------
a 100
b 200
d 200
e 500-----------------till here it has to come in ascending order ignoring 'c'
c 300
c 400
c 600
答案 0 :(得分:1)
您可以使用以下查询并相应地修改
select name,salary,(select count(name) from table_name where name=a.name) count_nm from table_name a order by count_nm,salary;
希望这有帮助!