GROUP BY and DISTINCT, on the other hand, have their own uses. In some cases, GROUP BY cannot replace DISTINCT, and DISTINCT cannot replace GROUP BY. It is up to you to optimise both of them and decide where to apply GROUP BY and DISTINCT based on your preferences and circumstances.
You may utilise aggregate functions like AVG, MAX, MIN, SUM, and COUNT with GROUP BY. DISTINCT, on the other hand, only removes duplicates. This will give you one row for each department, with the department name and the sum of all the amount values in all of the rows for that department.
DISTINCT is used to separate unique records from the rest of the table's records. Duplicate rows are removed. SELECT DISTINCT will always be the same as a GROUP BY, if not faster.
In AWS Redshift, GROUP BY is also faster than DISTINCT since GROUP BY utilises an XN HashAggregate while DISTINCT uses an XN Unique.
A group by is used to group a selected set of rows into summary rows using one or more columns or an expression. Distinct is used to find unique/distinct records, whereas a group by is used to group a selected set of rows into summary rows using one or more columns or an expression. When there is no aggregate function, group by produces the same result as distinct.
Learner's Ratings
4.2
Overall Rating
63%
21%
7%
5%
4%
Reviews
B
Boobalan A
5
I want this course for english. Classes are superb. but not understand few places, because I don't know hindi.
A
abhay
5
best course
A
Anish Narang
5
Best Course in Market till now
N
Nitish Kumar Sharma
4
Meet Shah is the worst teacher i have found in learnvern platform please replace his video with some other teacher he is unable to explain concept properly and sometimes he explain concept incorrect.
S
Sonu sonu
5
very good
I
Islam Web
5
Nice
R
Ravi Ranjan Tiwari
5
I am very happy that I am studying from LearnVern.
Share a personalized message with your friends.