Top 10 SQL Performance Tips 2

Another tip :

“Don’t use DISTINCT when you have or could use GROUP BY”

I prefer to use GROUP BY than DISTINCT since I can retrieve more field.

SELECT DISTINCT town_name from city;

SELECT town_id, town_zip, town_name from city group by town_name;

the result also not quite accurate using DISTINCT, I still have duplicate data.

Keep learn, get new stuff icon smile Top 10 SQL Performance Tips 2