Data Structure Study in MS SQL Server Exercise - F Distribution Tables

Purpose: Transform the traditional F-Distribution Table into unpivot table which is easier to search via SQL.

Original Table: Below is table with alpha = 0.1.



Query: 

 

Select '0.1' Alpha, [Df1], [Df2] , Value
FROM 
(
SELECT * 
FROM [FTable].['0_10']
) p
UNPIVOT
(Value FOR [Df1] IN 
([1], [2], [3], [4], [5] , [6], [7], [8], [9], [10], [12], [15], [20], [24], [30], [40], [60], [120], [Infinity])
)AS unpvt

Union all

Select '0.05' Alpha, [Df1], [Df2] , Value
FROM 
(
SELECT * 
FROM [FTable].['0_05']
) p
UNPIVOT
(Value FOR [Df1] IN 
([1], [2], [3], [4], [5] , [6], [7], [8], [9], [10], [12], [15], [20], [24], [30], [40], [60], [120], [Infinity])
)AS unpvt

Union all

Select '0.025' Alpha, [Df1], [Df2] , Value
FROM 
(
SELECT * 
FROM [FTable].['0_025']
) p
UNPIVOT
(Value FOR [Df1] IN 
([1], [2], [3], [4], [5] , [6], [7], [8], [9], [10], [12], [15], [20], [24], [30], [40], [60], [120], [Infinity])
)AS unpvt

Union all


Select '0.01' Alpha, [Df1], [Df2] , Value
FROM 
(
SELECT * 
FROM [FTable].['0_01']
) p
UNPIVOT
(Value FOR [Df1] IN 
([1], [2], [3], [4], [5] , [6], [7], [8], [9], [10], [12], [15], [20], [24], [30], [40], [60], [120], [Infinity])
)AS unpvt

Union all


Select '0.001' Alpha, [Df1], [Df2] , Value
FROM 
(
SELECT * 
FROM [FTable].['0_001']
) p
UNPIVOT
(Value FOR [Df1] IN 
([1], [2], [3], [4], [5] , [6], [7], [8], [9], [10], [12], [15], [20], [24], [30], [40], [60], [120], [Infinity])
)AS unpvt



New Table:



Enjoy it :) Thank you!

Comments