在要对chinesecredit进行生序排序,Englishcredit进行降序排序,怎么办?(用一条SQL语句) ---------------------------------------- SELECT * FROM 表 order by chinesecredit asc ,Englishcredit desc
select * from tb order by chinesecredit asc,Englishcredit desc
select * from tb order by chinesecredit ,Englishcredit desc
ankor(夜猫子) 你的那个查询不对,如果按照你的查询,结果两个字段都会是升序排序
我沒覺得他們寫的不對對多列同時排序時,肯定是優先排序緊跟在order by後面的那個字段,然後在前面字段排序的基礎上再依次排序後面的字段每一行的數據是固定不會變的,難道你想把 a 1 b 2 c 3 d 4 排成 a 4 b 3 c 2 d 1 這樣不成?
create table #(col nvarchar(10),col2 nvarchar(10),col3 nvarchar(10)) insert into # select '1','4','aa' union all select '1','3','bb' union all select '2','2','cc' union all select '3','2','dd' union all select '4','1','ee' go --lz注意col2列的变化 select * from # order by col asc,col2 desc select * from # order by col asc,col2 asc
----------------------------------------
SELECT * FROM 表 order by chinesecredit asc ,Englishcredit desc
你的那个查询不对,如果按照你的查询,结果两个字段都会是升序排序
a 1
b 2
c 3
d 4
排成
a 4
b 3
c 2
d 1
這樣不成?
insert into #
select '1','4','aa' union all
select '1','3','bb' union all
select '2','2','cc' union all
select '3','2','dd' union all
select '4','1','ee'
go
--lz注意col2列的变化
select * from # order by col asc,col2 desc
select * from # order by col asc,col2 asc
----------------------
你去测试一下就知道他们对不对了.
---------------------------
你说得没错,我就是要做成你说的那样,有没有可能实现成你那样的结果?
12 35
25 45
45 56
56 47
90 85