Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 using distinct and where????

Author  Topic 

pmccann1
Posting Yak Master

107 Posts

Posted - 2009-04-07 : 05:28:59
i am doing a select statment but when i use the distinct and where in it the results are wrong can this not be done?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-07 : 05:32:52
It will be hard for us to tell without seeing the actual code used in your scenario above.


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-04-07 : 05:33:25
can u post sample data and sample output?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-04-07 : 10:01:24
quote:
Originally posted by pmccann1

i am doing a select statment but when i use the distinct and where in it the results are wrong can this not be done?


probably what you're looking at is distinct set of some columns value alone. when you use distinct it is applied only for entire result set so that if any of involved columns have unique values it will return all instances of that column causing other column values to duplicate. If thats your concern, you should group on columns you want distinct values for and apply aggregation like sum(),max(),min(),... over others. if you need more help, post some data and illustrate your problem.
Go to Top of Page
   

- Advertisement -