Count distinct value pairs in multiple columns in SQL

前端 未结 5 1982
终归单人心
终归单人心 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:24

    Another (probably not production-ready or recommended) method I just came up with is to concat the values to a string and count this string distinctively:

    SELECT count(DISTINCT concat(id, name, address)) FROM mytable;
    

提交回复
热议问题