Za vse ki poznate SQL - kolega mi je danes poslal naslednjo kodo:
WITH
XGEN(X, IX) AS ( -- X DIM GENERATOR
SELECT CAST(-2.2 AS FLOAT) AS X, 0 AS IX UNION ALL
SELECT CAST(X + 0.031 AS FLOAT) AS X, IX + 1 AS IX
FROM XGEN
WHERE IX < 100
),
YGEN(Y, IY) AS ( -- Y DIM GENERATOR
SELECT CAST(-1.5 AS FLOAT) AS Y, 0 AS IY UNION ALL
SELECT CAST(Y + 0.031 AS FLOAT) AS Y, IY + 1 AS IY
FROM YGEN
WHERE IY < 100
),
Z(IX, IY, CX, CY, X, Y, I) AS ( -- Z POINT ITERATOR
SELECT IX, IY, X, Y, X, Y, 0
FROM XGEN, YGEN
UNION ALL
SELECT IX, IY, CX, CY, X * X - Y * Y + CX AS X, Y * X * 2 + CY, I + 1
FROM Z
WHERE X * X + Y * Y < 16
AND I < 100
)
SELECT REPLACE(REPLACE(REPLACE(REPLAC
REPLACE(REPLACE(REPLACE(REPLAC
REPLACE(REPLACE(REPLACE(REPLAC
(X0+X1+X2+X3+X4+X5+X6+X7+X8+X9
X20+X21+X22+X23+X24+X25+X26+X2
X40+X41+X42+X43+X44+X45+X46+X4
X60+X61+X62+X63+X64+X65+X66+X6
X80+X81+X82+X83+X84+X85+X86+X8
'A',' '), 'B','.'), 'C',','), 'D',','), 'E',','), 'F','-'), 'G','-'),
'H','-'), 'I','-'), 'J','-'), 'K','+'), 'L','+'), 'M','+'), 'N','+'),
'O','%'), 'P','%'), 'Q','%'), 'R','%'), 'S','@'), 'T','@'), 'U','@'),
'V','@'), 'W','#'), 'X','#'), 'Y','#'), 'Z',' ')
FROM (
SELECT 'X' + CAST(IX AS VARCHAR) AS IX,
IY, SUBSTRING('
FROM Z) ZT
PIVOT (
MAX(I) FOR IX IN (
X0,X1,X2,X3,X4,X5,X6,X7,X8,X9,
X20,X21,X22,X23,X24,X25,X26,X2
X40,X41,X42,X43,X44,X45,X46,X4
X60,X61,X62,X63,X64,X65,X66,X6
X80,X81,X82,X83,X84,X85,X86,X8
) AS PZT
Display je treba preklopiti v tekst... za vse ki nimate SQL-a... slikica pride v naslednjih dneh :)
No comments:
Post a Comment