Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How would you write a single SQL statement to get the output as: Col1 val x 1 y 2 z 3 (Note; Hardcoding not allowed.)

user-image
Question added by mirza habeeb , Application Support & Database Developer , Via Technology
Date Posted: 2015/03/30
Biju Jose
by Biju Jose , Analyst Programmer , AgilityCIS

WITH cte(col1)      AS (SELECT 'x'          UNION          SELECT 'y'          UNION          SELECT 'z') SELECT col1,        Row_number()          OVER(            ORDER BY col1) AS val FROM   cte 

 

HTH

More Questions Like This