Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DISTINCT vs GROUP BY

Status
Not open for further replies.

mbabcock

Programmer
Jul 25, 2006
32
US
Assuming an index on cCustNum field, which would be better in terms of performance?

1) select distinct cCustNum from MyTable where <somecondition>

2) select cCustNum from MyTable where <somecondition> GROUP BY cCustNum

QA's estimated execution plan seems to show that these are identical, but I thought I had heard some time ago that GROUP BY was optimizable moreso that DISTINCT.

BOL seems to give no clear indication when I searched.

tia!
--Michael
 
With an index on the column they should perform the same.

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005) / MCITP Database Administrator (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top