Reputation: 169
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:
Thanks , How? , News!
Upvotes: 0
Views: 78
Reputation: 60448
Just select the top 3 and order by MaxVisited
and (if necessary) the Id
column
SELECT TOP 3 Title from [TableName]
order by MaxVisited, Id desc
Upvotes: 3
Reputation: 28403
Try this
SELECT TOP 3 Title
From [TableName]
order by MaxVisited,Title desc
Upvotes: 1