Are these two queries the same - GROUP BY vs. DISTINCT?

前端 未结 8 1791
無奈伤痛
無奈伤痛 2021-01-05 07:38

These two queries seem to return the same results. Is that coincidental or are they really the same?

1.

SELECT t.ItemNumber,
  (SELECT TOP 1 ItemDes         


        
8条回答
  •  暖寄归人
    2021-01-05 08:21

    Since you're not using any aggregate functions, SQL Server should be smart enough to treat the GROUP BY as a DISTINCT.

    You may also be interested in checking out the following Stack Overflow post for further reading on this topic:

    • Is there any difference between Group By and Distinct?

提交回复
热议问题