Anatoly Lubarsky

Logo
MSSQL, .NET, Design. Life and Music

T-SQL: The Rozenshtein Method

The Rozenshtein Method is a method used in T-SQL for crosstab queries and pivoting. Stephen Forte explains:


"This method uses Boolean aggregates, so that each column has a numeric expression that resolves each row as a zero or one and that value (0 or 1) is multiplied by your numeric expression (Like TotalSales or (UnitPrice*Quantity)."


The query uses the following logical expression:


ABS(SIGN(expression))

SIGN evaluates the expression to 1 or 0 or -1, ABS reduces it to 0 or 1, so we get aka boolean aggregate. Impressive. It reminds me using ISNULL for conditional search queries.


[ via Mladen ]


Related Posts:

Sunday, July 09, 2006 1:38 AM

Comments

# Interesting Finds: July 9, 2006

7/9/2006 7:26 PM by Jason Haley

If your feedback doesn't appear right away, please be patient as it may take a few minutes to publish.

Post a Comment

Protected by CAPTCHAEnter the code you see
Name (*)  
E-mail (*)  
Url
Remember

Comment (*)