Both generates the same query plan.
Use DISTINCT with few duplicates
Use GROUP BY with many duplicates
By using DISTINCT, we can find unique rows and eliminate duplicate rows in the table.
Eg:- Select Distinct(ColumnName) from tablename;
Whenever we are using aggregate operators like min, max, sum, count etc we can use GROUP BY .
Eg:-Select empid,min(salary),max(salary),sum(salary) from emp group by empid;
Use DISTINCT with few duplicates
Use GROUP BY with many duplicates
By using DISTINCT, we can find unique rows and eliminate duplicate rows in the table.
Eg:- Select Distinct(ColumnName) from tablename;
Whenever we are using aggregate operators like min, max, sum, count etc we can use GROUP BY .
Eg:-Select empid,min(salary),max(salary),sum(salary) from emp group by empid;
No comments:
Post a Comment