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

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

有帮助吗?

解决方案

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top