How you can print 1 to 10 table using SQL Query, HCL

Asked in HCL interview(my friend faced this questions experience 6 years)
For print table you can use CTE as below, (you can copy query from comment section)
Please share your solution as well

 

Comments

  1. ;WITH CTE AS
    (
    SELECT 0 TableOf1, 0 TableOf2,
    0 TableOf3,0 TableOf4,0 TableOf5,
    0 TableOf6,0 TableOf7,0 TableOf8,
    0 TableOf9,0 TableOf10
    UNION ALL
    SELECT TableOf1 + 1, TableOf2 + 2,
    TableOf3 + 3, TableOf4 + 4, TableOf5 + 5,
    TableOf6 + 6, TableOf7 + 7, TableOf8 + 8,
    TableOf9 + 9, TableOf10 + 10
    FROM CTE WHERE TableOf1 < 10
    )
    SELECT * FROM CTE WHERE TableOf1 <> 0

    ReplyDelete

Contact Form

Send