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 ]
Sunday, July 9, 2006 1:38 AM