Duplicate
Is there a difference between GROUP BY and DISTINCT
Already discussed here
If you want to listen here
The Well and by group has its own meaning.
Distinct is used to filter unique records from records matching the query criteria.
The group by clause is used to group data on which aggregate functions are run, and the output is returned based on the columns in the group by clause. It has its own limitations, such as all columns that are in the select query, in addition to aggregated functions, should be part of the Group by clause.
Thus, even if you can have the same data returned by separate and group sentences, it is better to use different ones. See the example below.
select col1,col2,col3,col4,col5,col6,col7,col8,col9 from table group by col1,col2,col3,col4,col5,col6,col7,col8,col9
can be written as
select distinct col1,col2,col3,col4,col5,col6,col7,col8,col9 from table
This will make your life easier when there are more columns in the selection list. But at the same time, if you need to display the sum (col10) along with the above columns, you will have to use Group By. In this case, the different ones will not work.
eg,
select col1,col2,col3,col4,col5,col6,col7,col8,col9,sum(col10) from table group by col1,col2,col3,col4,col5,col6,col7,col8,col9
Hope this helps.