I want write a stored proc in T-SQL to return the top 5 most highly 开发者_运维百科rated and the bottom 5 most lowly rated articles from an Articles table, determined by the 'rating' column.
I was thinking of using a union on two selects but I'm not sure how to write it.
select * from (select top 5 *, 'Bottom Five' as Ranking from Call order by id ) a
union all
select * from (select top 5 *, 'Top Five' as Ranking from Call order by id desc ) b
精彩评论