sql query to find the duplicate records

后端 未结 5 1160
谎友^
谎友^ 2020-12-31 07:24

what is the sql query to find the duplicate records and display in descending, based on the highest count and the id display the records.

for example:

gettin

5条回答
  •  Happy的楠姐
    2020-12-31 08:04

    This query uses the Group By and and Having clauses to allow you to select (locate and list out) for each duplicate record. The As clause is a convenience to refer to Quantity in the select and Order By clauses, but is not really part of getting you the duplicate rows.

    Select
        Title,
        Count( Title ) As [Quantity]
       From
        Training
       Group By
        Title
       Having 
        Count( Title ) > 1
       Order By
        Quantity desc
    

提交回复
热议问题