Question: What is the difference between DISTINCT and GROUP BY?

Answer:
A DISTINCT and GROUP BY usually generate the same query plan, so performance should be the same across both query constructs. GROUP BY should be used to apply aggregate operators to each group. If all you need is to remove duplicates, then use DISTINCT. If you are using sub-queries execution plan for that query varies so in that case you need to check the execution plan before making decision of which is faster.


Example of DISTINCT:
Select Distinct Employee, Rank from Employees


Example of GROUP BY:
Select Employee, Rank From Employees Groub By Employee,Rank


Example of GROUP BY with aggregate function:
Select Employee, Rank, Count(*) EmployeeCount From Employees Group by Employee,Rank