What is the use of WITH TIES keyword in SELECT statement in SQL Queries?

前端 未结 7 1427
醉梦人生
醉梦人生 2021-01-30 20:15
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

7条回答
  •  离开以前
    2021-01-30 20:27

    Check this query and will be more clear.

    SELECT TOP 5 WITH TIES *
    FROM MyTable 
    ORDER BY ID;
    

    RESULT:- 1 2 3 4 5 5

    SELECT TOP 5 *
    FROM MyTable 
    ORDER BY ID;
    

    RESULT:- 1 2 3 4 5

提交回复
热议问题