sql group by versus distinct

后端 未结 5 1865
予麋鹿
予麋鹿 2020-12-01 10:30

Why would someone use a group by versus distinct when there are no aggregations done in the query?

Also, does someone know the group by versus distinct performance c

5条回答
  •  执念已碎
    2020-12-01 10:44

    Both would generate the same query plan in MS SQL Server.... If you have MS SQL Server you could just enable the actual execution plan to see which one is better for your needs ...

    Please have a look at those posts:

    http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/

    http://www.sqlmag.com/Article/ArticleID/24282/sql_server_24282.html

提交回复
热议问题