Avatar of vbnetcoder
 asked on

SQL Custom sorting

I need to be able to custom sort values that come from a query basically i have a query like this

SELECT Name from Table

and i want to be able to custom order the values

Ideally, it would add an extra field to the SQL query at runtime so the result would be something like this

Name             SortOrder
John               1
Sam               2
Susan           3
Andy            4
Microsoft SQL Server 2008SQL

Avatar of undefined
Last Comment
Jim Horn

8/22/2022 - Mon
Jim Horn

Expand on 'custom sort'.  Are you trying to get an incrementing integer value for each name, or establishing a sort order other than A-Z name?

establishing a sort order other than A-Z name?

sorry: My comment was a statement in answer to your question not intended to be a question.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Jim Horn

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question