Posts Tagged ‘ SQL ’

Combining contiguous date ranges in a SQL query – using CTE recursion

Nov 6th, 2008 | By Christian Donner | Category: SQL Server

Sometimes we need to reduce the granularity of date ranges by combining serveral contiguous rows into one. While this is a common classic SQL problem, I was unable to find an elegant solution that also performs well, and came up with my own. This article explains the problem and outlines the solution using a Common [...]



SQL Server 2005 – Recursion

May 3rd, 2008 | By Christian Donner | Category: SQL Server

Why do I find all the examples of how to use recursion in SQL Server 2005 too complicated (including the one in the Microsoft help)?
Here is mine that does the bare minimum.



Using SQL Server Column Aliases

Mar 14th, 2008 | By Christian Donner | Category: SQL Server

When you have query that does complex calculations, maybe even has function calls in the select list

select
costly_function_A() as result_A,
costly_function_B() as result_B
from
table_T

and then you need to return the result of such a calculation, but also [...]