I learned something simple about SQL the other day:SELECT c FROM myTbl GROUP BY CHas the same result as:SELECT DISTINCT C FROM myTblWhat I am curious of, is there anything different in the way an SQL engine processes the command, or are they truly the same thing?I personally prefer the distinct syntax, but I am sure it's more out of habit than anything else.EDIT: This is not a question about aggregates. The use of GROUP BY with aggregate functions is understood. 解决方案 MusiGenesis' response is functionally the correct one with regard to your question as stated; the SQL Server is smart enough to realize that if you are using "Group By" and not using any aggregate functions, then what you actually mean is "Distinct" - and therefore it generates an execution plan as if you'd simply used "Distinct."However, I think it's important to note Hank's response as well - cavalier treatment of "Group By" and "Distinct" could lead to some pernicious gotchas down the line if you're not careful. It's not entirely correct to say that this is "not a question about aggregates" because you're asking about the functional difference between two SQL query keywords, one of which is meant to be used with aggregates and one of which is not.A hammer can work to drive in a screw sometimes, but if you've got a screwdriver handy, why bother?(for the purposes of this analogy, Hammer : Screwdriver :: GroupBy : Distinct and screw => get list of unique values in a table column) 这篇关于GROUP BY 和 DISTINCT 之间有什么区别吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!