0

我想在 T-SQL 中编写一个存储过程,以返回文章表中评分最高的 5 篇文章和评分最低的 5 篇文章,由“评分”列确定。

我正在考虑在两个选择上使用联合,但我不确定如何编写它。

4

1 回答 1

3
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
于 2010-09-14T16:56:31.720 回答