22,302
社区成员




select Sh_dTGold.Tid,Sh_dTGold.Tprice,Sh_dTGold.Tquantity,Sh_dTGold.Tstate,Sh_Game.Gname,Sh_Server.Sname
from Sh_TGold,Sh_Game,Sh_Server
where Sh_dTGold.Gid = Sh_Game.Gid
and Sh_dTGold.Sid = Sh_Server.Sid
and Sh_dTGold.Gid =1 order by Sh_Server.Sname, Tquantity desc
/*
if object_id('tempt') is not null drop table tempt
--go
create table tempt (uid int,class int)
insert tempt
select 6, 1 union all
select 5, 2 union all
select 4, 3 union all
select 3, 4 union all
select 2, 5 union all
select 1, 6
*/
DECLARE @tmp_a TABLE (id int identity(1,1),uid int )
insert @tmp_a
select uid from tempt order by uid
DECLARE @tmp_b TABLE (id int identity(1,1),class int )
insert @tmp_b
select class from tempt order by class desc
select a.uid,b.class
from @tmp_a a
inner join @tmp_b b on a.id=b.id
/*
1 6
2 5
3 4
4 3
5 2
6 1
*/
DECLARE @tmp_Table TABLE (id int identity(1,1),Tid int )
order by Sh_Server.Sname, Sh_dTGold.Tquantity desc
select uid,class from
(select id=row_number()over (order by uid ASC),uid from tb ) a inner join
(select id=row_number()over (order by class deSC),class from tb ) b
on a.id=b.id
select a.Sname,b.Tquantity,a.Tid,a.Tprice,a.Tstate,a.Gname
from
(select id1=row_number() over(order by Sh_Server.Sname asc)
,Sh_dTGold.Tid,Sh_dTGold.Tprice,Sh_dTGold.Tstate,Sh_Game.Gname,Sh_Server.Sname --这里少了Sh_dTGold.Tquantity
from Sh_TGold,Sh_Game,Sh_Server
where Sh_dTGold.Gid = Sh_Game.Gid and Sh_dTGold.Sid = Sh_Server.Sid
and Sh_dTGold.Gid =1) A
inner join
(select id2=row_number() over(order by Tquantity desc)
,Sh_dTGold.Tid,Sh_dTGold.Tprice,Sh_dTGold.Tquantity,Sh_dTGold.Tstate --这里少了Sh_Server.Sname
from Sh_TGold,Sh_Game,Sh_Server
where Sh_dTGold.Gid = Sh_Game.Gid and Sh_dTGold.Sid = Sh_Server.Sid
and Sh_dTGold.Gid =1) B
on A.id1=B.id2
--注a.Tid,a.Tprice,a.Tstate,a.Gname顺序可能会打乱