SQL distinct for 2 fields in a database

前端 未结 5 1784
时光取名叫无心
时光取名叫无心 2020-12-04 17:35

Can you get the distinct combination of 2 different fields in a database table? if so, can you provide the SQL example.

5条回答
  •  囚心锁ツ
    2020-12-04 17:55

    If you still want to group only by one column (as I wanted) you can nest the query:

    select c1, count(*) from (select distinct c1, c2 from t) group by c1
    

提交回复
热议问题