It's simple question if a query have both distinct and group by (it may be a stupid one). Is it have any performance draw back? Which one will be used to get differenct values. select distinct column1, column2 from table group by column1, column2
Though you have got the answer I would like to refer you to review Estimated execution plan from the query analyzer next time when you would like to see such plans.
[quote user="Ramachandran"] It's simple question if a query have both distinct and group by (it may be a stupid one). Is it have any performance draw back? Which one will be used to get differenct values. select distinct column1, column2 from table group by column1, column2 [/quote] When you use distinct you dont need group by and vice versa [] Somewhere I read group by is faster than Distinct for millions of rows
In most cases you will find that identical queries plans are generated for both approaches, however to me it is more natural and logical to use a DISTINCT when I need to determine different values and a GROUP BY when I need to perform some aggregation.
In the most of the cases whether it is 100 rows or million rows it fetches same results in execution time, for the OP information here is http://blog.sqlauthority.com/2007/0...n-distinct-and-group-by-distinct-vs-group-by/ the explanation.