Special Sort Order T'sql

Clive Wightman 121 Reputation points
2021-10-15T15:12:50.077+00:00

I Have been asked to pull data from a table in like the screen shot.

140893-image.png

Any ideas how I can get the zones to appear like the above

instead of like the current way, below.![140916-image.png][2]

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
{count} votes

1 answer

Sort by: Most helpful
  1. EchoLiu-MSFT 14,626 Reputation points
    2021-10-18T02:25:12.827+00:00

    Hi @Clive Wightman

    Welcome to the microsoft TSQL Q&A forum!

    If you just want to get the output in the first screenshot, please refer to:

     SELECT Zone752,Zone753,Zone754,Zone755,Zone791,Zone792,  
     Zone5,Zone6,Zone7,Zone8,Zone9,Zone10,Zone11  
     FROM yourtable  
    

    The order of the columns will be returned in the order you listed in the SELECT statement.

    If you have any question, please feel free to let me know.

    Regards
    Echo


    If the answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.