This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create procedure dbo.dynamic_simple_contingency_table_query | |
@withExpression nvarchar(max) -- ^ optional with CTE expression | |
, @selectStatement nvarchar(max) -- ^ select statement, should return at least three columns, whose name matches following parameters | |
, @row_column_key nvarchar(max) -- ^ column name which identifies row keys (result will have as many distinct rows as found here) | |
, @column_column_key nvarchar(max) -- ^ column name which identifies column keys (result will have as many distinct values as found here) | |
, @fact_column_key nvarchar(max) -- ^ column name which contains facts | |
as | |
begin | |
declare @sql nvarchar(max) | |
set @sql = @withExpression |