|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 5:22 PM
Points: 6,998,
Visits: 13,951
|
|
Comments posted to this topic are about the item Windowed Aggregate functions
---------------------------------------------------------------------------------- Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Yesterday @ 6:52 AM
Points: 2,018,
Visits: 2,852
|
|
Good question. I love learning new things and this is a new one on me. I can keep this for my bag of tricks.
Is there a downside to doing this? The code is clean but my gut feeling is there may be some inefficiencies. Are there any gotchas?

|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 5:22 PM
Points: 6,998,
Visits: 13,951
|
|
The gotcha is in the Windowed aggregate itself. It's a bit RBAR-like in that it seems to create a worktable with LOOP joins to the outer query, so its perf tends to suffer a lot with the "window" you're running this against is large. Meaning - if you were to need something like a "percentage of total", and your unsummarized data was large, it would likely be more efficient to use a derived table setup to create the "total", since you can control what method is used to link it into the main query.
On the other hand, if you need quick access to different aggregates (especially ones aggregated against different groupings), and the groups aren't huge, it tends to do VERY well.
---------------------------------------------------------------------------------- Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Monday, April 06, 2009 1:29 PM
Points: 2,057,
Visits: 215
|
|
| I think the point of the question is that unless you know how windowed aggregation works, it is a gotcha.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 5:22 PM
Points: 6,998,
Visits: 13,951
|
|
Steven Cameron (6/27/2008) I think the point of the question is that unless you know how windowed aggregation works, it is a gotcha.
That's certainly a good way to describe it! Although this particular behavior is laid out in ANSI's definition, it's certainly not incredibly well documented elsewhere (and not mentioned per se on Ms' side), so I've actually seen it being disclaimed as "a bug".
---------------------------------------------------------------------------------- Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 9:22 AM
Points: 551,
Visits: 1,150
|
|
| Awesome question, I've actually used the Window functions in the past and the Group By almost got me!
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 12:39 PM
Points: 5,103,
Visits: 20,220
|
|
That's certainly a good way to describe it! Although this particular behavior is laid out in ANSI's definition, it's certainly not incredibly well documented elsewhere (and not mentioned per se on Ms' side), so I've actually seen it being disclaimed as "a bug".
Now this has me wondering how many other items MS tech writers of BOL have missed or failed to properly communicate with MS development teams about.
Thanks, now I have to determine where to keep that link you provided for my own future reference
If everything seems to be going well, you have obviously overlooked something.
Ron
Please help us, help you -before posting a question please read Before posting a performance problem please read
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, February 05, 2013 5:17 PM
Points: 41,
Visits: 102
|
|
I received this error while running the query? Msg 156, Level 15, State 1, Line 17 Incorrect syntax near the keyword 'OVER'.
Any idea?
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 5:22 PM
Points: 6,998,
Visits: 13,951
|
|
thuybui (6/27/2008) I received this error while running the query? Msg 156, Level 15, State 1, Line 17 Incorrect syntax near the keyword 'OVER'.
Any idea?
Are you running this in 2005 "native"? meaning - in compatibility 90?
---------------------------------------------------------------------------------- Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, February 05, 2013 5:17 PM
Points: 41,
Visits: 102
|
|
Yes, Microsoft SQL Server Management Studio 9.00.1399.00
|
|
|
|