日期:2014-05-18 浏览次数:20604 次
declare @t table(ID int,num1 int,num2 float,date char(10),name char(10)) insert into @t select 01,2,1.3,'09-01','as' insert into @t select 02,1,-1,'09-02','ss' insert into @t select 03,1,-1,'09-01','as' insert into @t select 03,1,-1,'09-01','ss' insert into @t select 04,1,-0.5,'09-02','ss' select * from @t select * from @t order by num1 asc,num2 desc,date asc ,name desc /* ID num1 num2 date name ----------- ----------- ---------------------- ---------- ---------- 1 2 1.3 09-01 as 2 1 -1 09-02 ss 3 1 -1 09-01 as 3 1 -1 09-01 ss 4 1 -0.5 09-02 ss (5 row(s) affected) ID num1 num2 date name ----------- ----------- ---------------------- ---------- ---------- 4 1 -0.5 09-02 ss 3 1 -1 09-01 ss 3 1 -1 09-01 as 2 1 -1 09-02 ss 1 2 1.3 09-01 as (5 row(s) affected) */
------解决方案--------------------
declare @t table(ID int,num1 int,num2 float,date char(10),name char(10)) insert into @t select 01,2,1.3,'09-01','as' insert into @t select 02,1,-1,'09-02','ss' insert into @t select 03,1,-1,'09-01','as' insert into @t select 03,1,-1,'09-01','ss' insert into @t select 04,1,-0.5,'09-02','ss' select * from @t select * from @t order by num1 asc,num2 desc,date asc ,name desc /* ID num1 num2 date name ----------- ----------- ---------------------- ---------- ---------- 1 2 1.3 09-01 as 2 1 -1 09-02 ss 3 1 -1 09-01 as 3 1 -1 09-01 ss 4 1 -0.5 09-02 ss (5 row(s) affected) ID num1 num2 date name ----------- ----------- ---------------------- ---------- ---------- 4 1 -0.5 09-02 ss 3 1 -1 09-01 ss 3 1 -1 09-01 as 2 1 -1 09-02 ss 1 2 1.3 09-01 as (5 row(s) affected) */
------解决方案--------------------