WITH Constants(one,half,root5,phi,phi2,phi4,phi8,phi16,phi32,phi64) AS (SELECT CAST(1.0 AS DECIMAL(38,20)), CAST(0.5 AS DECIMAL(38,20)), CAST(2.2360679774997896964091736687313 AS DECIMAL(38,20)), CAST(1.6180339887498948482045868343656 AS DECIMAL(38,20)), CAST(2.6180339887498948482045868343656 AS DECIMAL(38,20)), CAST(6.8541019662496845446137605030969 AS DECIMAL(38,20)), CAST(46.978713763747791812296323521678 AS DECIMAL(38,20)), CAST(2206.9995468961462151779272055189 AS DECIMAL(38,20)), CAST(4870846.9999997946968976853425802 AS DECIMAL(38,20)), CAST(23725150497406.999999999999957851 AS DECIMAL(38,20)))SELECT n.Number, CAST(CAST((CASE WHEN n.Number & 64 = 0 THEN c.one ELSE c.phi64 END * CASE WHEN n.Number & 32 = 0 THEN c.one ELSE c.phi32 END * CASE WHEN n.Number & 16 = 0 THEN c.one ELSE c.phi16 END * CASE WHEN n.Number & 8 = 0 THEN c.one ELSE c.phi8 END * CASE WHEN n.Number & 4 = 0 THEN c.one ELSE c.phi4 END * CASE WHEN n.Number & 2 = 0 THEN c.one ELSE c.phi2 END * CASE WHEN n.Number & 1 = 0 THEN c.one ELSE c.phi END) / c.root5 + c.half AS BIGINT) AS VARCHAR(20)) AS FibNumberFROM master.dbo.spt_values nCROSS JOIN Constants cWHERE n.type='P' AND n.Number BETWEEN 1 AND 92;