Count distinct value pairs in multiple columns in SQL

前端 未结 5 1970
终归单人心
终归单人心 2021-01-31 17:14

What query will count the number of rows, but distinct by three parameters?

Example:

Id      Name        Address 
==============================
1     My         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-31 17:40

    To get a count of the number of unique combinations of id, name and address:

    SELECT Count(*)
    FROM   (
            SELECT DISTINCT
                   id
                 , name
                 , address
            FROM   your_table
           ) As distinctified
    

提交回复
热议问题