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
 partition by distincts

Author  Topic 

sqlclarify
Yak Posting Veteran

56 Posts

Posted - 2009-05-10 : 02:55:58
Does adding distincts to a query interfere with partition by..?

I have a query

select
col1,
col2
sum col3 over (partition by col1)
from etc.etc.
which works fine if I don't add distinct to the select clause. But if I add distinct I get strange results. Does partition by get executed last in the query. Just curious.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-05-10 : 03:23:15
partition by takes sum after grouping on the specified field (col1). putting a distinct on select will cause only distinct combinations of records to be returned. what difference are you observing? can you be specific on that by giving some data sample?
Go to Top of Page
   

- Advertisement -