This article is half-done without your Comment! *** Please share your thoughts via Comment ***
Check the below input data and expected output to find Square of first ten number.
Expected Output:
1 2 3 4 5 6 7 8 9 10 11 12 |
SquareRoot ---------------------- 1 4 9 16 25 36 49 64 81 100 |
Solution:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
;WITH CTE AS ( SELECT DISTINCT Number ,SQUARE(number) SquareRoot FROM MASTER..SPT_VALUES number WHERE Number >= 1 AND Number <= 100 ) SELECT SquareRoot FROM CTE WHERE EXISTS ( SELECT DISTINCT number FROM MASTER..SPT_VALUES x WHERE x.number = CTE.SquareRoot AND x.Number >= 1 AND x.Number <= 100 ) |
Please try the different solution for this puzzle and share it via comment...