Click to See Complete Forum and Search --> : TSQL question (Stored Procedure)


Matrix.net
04-16-2007, 09:39 AM
Hello , I currently have a stored procedure in SQL2K that pulls certain fields using the distinct function . What it does is pull information from people in the database .

However, the problem is that there is more than 1 entry for some people and I only want data returned with only one instance of that person , not two records of the same person just because they differ by one of the fields. Is there a way I can say Select Distinct blah ,bla2 ,bla3 from TableBLA where (a field doesnt match the same field on the other rows ) ?

The current fields being pulled are critical so I cant remove any of the fields from the Select statement .

Hack
04-24-2007, 10:21 AM
Rather than use SELECT DISTINCT, add a GROUP BY clause.