January 18, 2012 at 10:08 pm
Comments posted to this topic are about the item The new Analytic functions in SQL Server 2012
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
January 19, 2012 at 2:39 am
Finally they will have what Oracle had delivered ages ago....
January 19, 2012 at 5:53 am
I finally see SQL Server catching up, I am so used to of Lead/Lag in DB2. It will make my life little easier. Thanks
January 19, 2012 at 6:01 am
WayneS (1/18/2012)
Comments posted to this topic are about the item <A HREF="/articles/SQL+Server+2012/76704/">The new Analytic functions in SQL Server 2012</A>
Great information, thanks for that.
To me it was not clear immediately, what the difference between the MAX Aggregate Window Function and LAST_VALUE(X) was. In the end MAX(x) OVER (PARTITION BY y)
should return the same as FIRST_VALUE(X) OVER (PARTITION BY Y, ORDER BY X DESC)
But obviously, the MAX / MIN Aggregate Window Functions do not allow you to order your partition by a different column before applying the aggregate. (And it actually does not really make sense to impose a different order on MAX or MIN.)
So the whole point of FIRST_VALUE and LAST_VALUE seem to be:
FIRST_VALUE(X) OVER (PARTITION BY Y, ORDER BY SomeOtherColumn DESC)
Any other points I may have missed?
Best Regards,
Chris Büttner
January 19, 2012 at 6:48 am
Any idea what the performance of these things is like?
January 19, 2012 at 7:55 am
Good Stuff Wayne
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
January 19, 2012 at 8:14 am
Great article Wayne. This is great info to have when management wants to know why we are always upgrading 😀
January 19, 2012 at 8:24 am
PERCENTILE_CONT / PERCENTILE_DISC
Lets recall from statistics that continuous variables (PERCENTILE_CONT) are those that "cannot not be exactly counted," while discrete variables (PERCENTILE_DISC) "have an exact amount."
PERCENTILE_CONT would be better used when performing estimation or predictive calculations, as you are trying to determine a value from a sample of data (where the entire data set is unknown).
PERCENTILE_DISC would be better for when we need an exact measure, and the entire data set is known.
**Note: I am not a statistician, nor an analytics guru, so hopefully someone with greater experience could shine some better light on this, or at least validate my statement.
Hopefully this helps some trying to understand the purposes behind these functions.
Stephen
January 19, 2012 at 8:30 am
Good article Wayne. One thing I like to see in articles like this though is how you might solve the same problem without using the new functions. Just to see how much the new functions help.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
January 19, 2012 at 12:41 pm
Thank you for this Wayne - I'll definitely come back to it later. I like your concise writing style with helpful examples too.
- Mark
The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking
January 19, 2012 at 1:14 pm
How do the newfangled Analytics functions compare with the Quirky Update method used for - among other things - creating running totals in term of performance ?
January 19, 2012 at 1:23 pm
Thanks - this is a great summary.
January 19, 2012 at 3:27 pm
Nice article, very helpful. It's nice to see articles like this with examples. Definitely helps to prove to others why upgrades are needed. 🙂
January 19, 2012 at 7:40 pm
Christian Buettner-167247 (1/19/2012)
WayneS (1/18/2012)
Comments posted to this topic are about the item <A HREF="/articles/SQL+Server+2012/76704/">The new Analytic functions in SQL Server 2012</A>Great information, thanks for that.
To me it was not clear immediately, what the difference between the MAX Aggregate Window Function and LAST_VALUE(X) was. In the end
MAX(x) OVER (PARTITION BY y)
should return the same asFIRST_VALUE(X) OVER (PARTITION BY Y, ORDER BY X DESC)
But obviously, the MAX / MIN Aggregate Window Functions do not allow you to order your partition by a different column before applying the aggregate. (And it actually does not really make sense to impose a different order on MAX or MIN.)
So the whole point of FIRST_VALUE and LAST_VALUE seem to be:
FIRST_VALUE(X) OVER (PARTITION BY Y, ORDER BY SomeOtherColumn DESC)
Any other points I may have missed?
Actually...
this article only talks about the Analytic functions. You might want to look at my previous article The OVER Clause enhancements in SQL Server code named “Denali”, CTP3[/url].
Basically, the MIN/MAX functions DO allow you to order your partition by a different column. But let's talk about this "over there"... it's more appropriate there.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
January 19, 2012 at 7:42 pm
RichB (1/19/2012)
Any idea what the performance of these things is like?
Did you click on that "TSQL Challenges Winner" icon in my signature? (Well, that is using the aggregate functions and not the analytic, but I believe them to be similar.)
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 15 posts - 1 through 15 (of 33 total)
You must be logged in to reply to this topic. Login to reply