0

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!
2
  • 2
    How/Why is News! selected in preference to bye? Commented Mar 3, 2014 at 8:03
  • yeah, bye and news! have same value (8) Commented Mar 3, 2014 at 8:06

3 Answers 3

3

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
Sign up to request clarification or add additional context in comments.

1 Comment

Maybe, right. I included the id column to ensure the requested result.
1

Try this

SELECT TOP 3 Title 
From [TableName] 
order by MaxVisited,Title desc

Comments

0
SELECT TOP 3 Title from [your_table] 
order by MaxVisited, ID desc

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.