例如下面的查詢:
select distinct id, name from user
1
是將 id 與 name 作為一個組合進行去重操作,如果想要指定按照其中的 id 字段進行去重可以用 group by 與 count 配合使用:
select id, name, count(distinct id) from user group by id, name
例如下面的查詢:
select distinct id, name from user
1
是將 id 與 name 作為一個組合進行去重操作,如果想要指定按照其中的 id 字段進行去重可以用 group by 與 count 配合使用:
select id, name, count(distinct id) from user group by id, name
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。