SELECT TOP 5 WITH TIES EmpNumber,EmpName
FROM Employee
Order By EmpNumber DESC
This above query return more than five result, What is the use of \"Wi
The WITH TIES allows you to return more rows with values that match the last row in the limited result set. Note that WITH TIES may cause more rows to be returned than you specify in the expression.
The selection of which the rows to return is nondeterministic.
This means that if you run the query again, without the underlying data changing, theoretically you could get a different set of three rows.
In practice, the row selection will depend on physical conditions like :
If you actually run the query multiple times, as long as those physical conditions don’t change, there’s some likelihood you will keep getting the same results. But it is critical to understand the “physical data independence” principle from the relational model, and remember that at the logical level you do not have a guarantee for repeatable results. Without ordering specification, you should consider the order as being arbitrary, resulting in a nondeterministic row selection.
Your current result is like below :
EmpNumber EmpName Ranking
11 Maria 1
23 José 2
456 Pedro 3
456 Pedro 3 --WITH TIES
Probably your table is containing duplicate rows or may have historical ones as in general the EmpNumber is unique.
From Reference