[英]Selecting three of Max() values of a field in sql server
Assume that i have three field in my database like this : 假设我的数据库中有三个字段,如下所示:
ID Title MaxVisited
1 hi 6
2 bye 8
3 How? 9
4 News! 8
5 Hey 3
6 Thanks 9
now i want to select Title three of max value of MaxVisited.. the result which i want: 现在我要选择MaxVisited最大值的标题三。我想要的结果:
Thanks , How? , News!
Just select the top 3 and order by MaxVisited
and (if necessary) the Id
column 只需选择前3个,然后按
MaxVisited
和(如果需要) Id
列进行MaxVisited
SELECT TOP 3 Title from [TableName]
order by MaxVisited, Id desc
Try this 尝试这个
SELECT TOP 3 Title
From [TableName]
order by MaxVisited,Title desc
SELECT TOP 3 Title from [your_table]
order by MaxVisited, ID desc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.