在pubs樣板測試:
1、使用臨時表
select identity(int,1,1) 'RowOrder',au_lname,au_fname into #tmpfrom authors
select * from #tmp
drop table #tmp
2、使用自連接
select rank=count(*), a1.au_lname, a1.au_fnamefrom authors a1
inner join authors a2 on a1.au_lname + a1.au_fname >= a2.au_lname + a2.au_fname
group by a1.au_lname, a1.au_fname
order by count(*)
沒有留言:
張貼留言