Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 123»»»

All the rows before this one Expand / Collapse
Author
Message
Posted Thursday, December 19, 2013 10:10 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 10:42 AM
Points: 31,083, Visits: 15,532
Comments posted to this topic are about the item All the rows before this one






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1524857
Posted Thursday, December 19, 2013 10:11 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 12:01 AM
Points: 1,746, Visits: 763
Nice question - thanks steve

Did a bit of digging...as another explanation

https://www.simple-talk.com/sql/learn-sql-server/window-functions-in-sql-server-part-2-the-frame/


Hope this helps...

Ford Fairlane
Rock and Roll Detective





Post #1524858
Posted Friday, December 20, 2013 1:36 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: 2 days ago @ 5:56 AM
Points: 1,415, Visits: 801
Hey Steve - nice easy one to finish the week.

Cheers.
Post #1524894
Posted Friday, December 20, 2013 7:22 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 10:13 AM
Points: 1,347, Visits: 2,333
LAG works for a fixed number of rows before the current row.
For all the rows prior to the current row, wouldn't you use something like ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW in the OVER clause?

https://www.simple-talk.com/sql/learn-sql-server/window-functions-in-sql-server-part-2-the-frame/

http://sqlmag.com/sql-server-2012/how-use-microsoft-sql-server-2012s-window-functions-part-1

https://www.simple-talk.com/sql/t-sql-programming/sql-server-2012-window-function-basics/
Post #1524981
Posted Friday, December 20, 2013 8:40 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Thursday, March 20, 2014 6:00 AM
Points: 588, Visits: 276
Steve, very nice question. Thanks
Post #1525027
Posted Friday, December 20, 2013 8:40 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 10:42 AM
Points: 31,083, Visits: 15,532
You would use unbounded preceding for all the rows. The title did say all the rows, but the question did not.






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1525028
Posted Friday, December 20, 2013 9:31 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 28, 2014 7:12 PM
Points: 2,148, Visits: 487
I am so glad SQL Server finally caught up to Oracle on making itself more ANSI-99 compliant in the area of "row based window frames". I always theorized MS intentionally did this to get customers to try SSAS. This, of course, is a baseless theory of mine that I could never prove. Does anyone know the REAL answer as to why it took so long?

I would also love to one day see a Modenar* regarding performance diffferences between native window framing in SQL 2012 vs pre-2012, more imaginative (sorta) solutions. As The Kimball Group once said "just because your RDBMS is ANSI compliant does NOT mean the RDBMS performs those operations well"!

Thanks, Steve!

*A Modenar is a passionate teaching to the SQL Server community on set-based data processing and all the tools available to do so in a tireless effort to rid the world of intra-database RBAR.

Post #1525060
Posted Friday, December 20, 2013 9:52 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 9:12 AM
Points: 1,838, Visits: 2,181
Nice question and good feature. Makes rolling calcs easier.

Please don't go. The drones need you. They look up to you.
Connect to me on LinkedIn
Post #1525076
Posted Friday, December 20, 2013 9:54 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 10:48 AM
Points: 4,126, Visits: 3,427
Nice, Steve, very nice - thanks!
Post #1525077
Posted Friday, December 20, 2013 11:59 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, September 29, 2014 9:17 AM
Points: 2,567, Visits: 1,038
That is a new piece of helpful information. Thanks!
Post #1525140
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse