Sql中top5 与 top5with ties区别

Sql中top5 与 top5with ties区别请具体说明用法,非常感谢
2025-03-24 21:50:30
推荐回答(2个)
回答1:

top 5是只取5行,
top 5 with ties是把和这5行有相同数据的行也取出来

回答2:

table1
id name
1 100
2 200
3 300
4 300
5 400
select top 3 * from table1
结果:
1 100
2 200
3 300
select top 3 with ties * from table1
结果:
1 100
2 200
3 300
4 300