SQL Sunday Word Scramble
SQL Server – TSQL Analytics Word Search Find the following words in the word scramble above. TOP RANK DENSE_RANK ROW_NUMBER NTILE OVER LAG LEAD FIRST_VALUE… Read More »SQL Sunday Word Scramble
SQL Server – TSQL Analytics Word Search Find the following words in the word scramble above. TOP RANK DENSE_RANK ROW_NUMBER NTILE OVER LAG LEAD FIRST_VALUE… Read More »SQL Sunday Word Scramble
Click on the grid to enlarge, then print it. Find the following words in the grid up, down, left, right, horizontal, vertical, and… Read More »SQL Sunday Fun – Word Search with New T-SQL 2012 Functionality
SQL Server 2012 adds many new features to Transact SQL (T-SQL). One of my favorites is the Rows and Range enhancements to the over clause.… Read More »Rows and Range, Preceding and Following
It has been a year since SQL Server 2012 released. There were some fun posts on Twitter about the SQL Server 2012 birthday or anniversary.… Read More »Happy Birthday SQL Server 2012
I am at SQL Saturday in Vancouver BC today. Here is the download of my presentation. Download zip file. Here is the presentation outline. OVER… Read More »SQL Saturday Presentation
So far after playing around with SQL Server 2012 there are many new features to SQL. Overall I think my favorites are in the Analytic… Read More »My Top 10 TSQL Enhancements in SQL Server 2012
For years I have heard the question of how can I do an IIF in TSQL? Honestly I never thought it would be that useful… Read More »IIF in TRANSACT SQL on SQL SERVER 2012
In a previous article I covered the usage of ROWS PRECEDING and FOLLOWING in the over clause. For this example I am going to use the same database and tables that I created in the previous example to show ROWS UNBOUNDED both PRECEEDING and FOLLOWING.
One of the new features available in TSQL in SQL Server 2012 is the ROWS UNBOUNDED PRECEDING and the ROWS UNBOUNDED FOLLOWING options. The UNBOUNDED option in available when using the PRECEDING and FOLLOWING options. Here’s how they work…
-- ROWS UNBOUNDED PRECEDING select Year, DepartmentID, Revenue, min(Revenue) OVER (PARTITION by DepartmentID ORDER BY [YEAR] ROWS UNBOUNDED PRECEDING) as MinRevenueToDate from REVENUE order by departmentID, year;
In this example, the MinRevenueToDate lists the lowest revenue for this row and all earlier rows ordered by date in the current department id.
You can see that row 1 sets the MinRevenueToDate to 10030, and it doesn’t change until row 7 with a lower revenue year.
Read More »Transact SQL OVER Clause – ROWS UNBOUNDED PRECEDING or FOLLOWING