Tag Archives: performance of distinct vs group by

What is difference between DISTINCT and GROUP BY?

DISTINCT and GROUP BY both are used to remove duplicates. Performance is same during both queries. So best practice to use DISTINCT is when there is no Aggregate function involved in the query. If any aggregate function is involved than GROUP BY should be used. Select query with DISTINCT Select query with GROUP BY