Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1113103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:48:19+00:00 2026-05-17T02:48:19+00:00

in this example : 10-20 20-40 50-60 v k r a 12 month 1

  • 0

in this example :

10-20
20-40
50-60

v
k
r
a

12 month
1 month

how can i sort it in this order ?:

10-20
20-40
50-60

a
k
r
v

1 month
12 month

i use abs(value) but in the alphabetical case doesn’t work

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:48:20+00:00Added an answer on May 17, 2026 at 2:48 am

    OK, thanks to the commenter, now a working version. This sorts on two cases in the order by clause:

    select  *
    from    (
            select '10-20' as col1
            union all select '20-40'
            union all select '50-60'
            union all select 'v'
            union all select 'k'
            union all select 'r'
            union all select 'a'
            union all select '12 month'
            union all select '1 month'
            ) s1
    order by
            case
                when col1 rlike '[0-9][0-9]-[0-9][0-9]' then 1
                when col1 rlike '[0-9]+ month' then 3
                else 2
            end
    ,       case
                when col1 rlike '[0-9][0-9]-[0-9][0-9]' then cast(col1 as decimal)
                when col1 rlike '[0-9]+ month' then cast(col1 as decimal)
                else col1
            end
    

    The first case puts categories in order: 00-00 first, then other stuff, and at the end the months. The second case converts the columns to decimal if possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello Trying to sort this list by Month and day. Can not get it
I want to use custom List adapter in this example so that I can
I have URL scheme for my blog like this: http://www.example.com/%YEAR%/%MONTH%/%CATEGORY%/%POST_TITLE%/ Now i want to
This example is simplified a bit, but in my ASP.NET web page in my
This example working great because here containment is body http://jsfiddle.net/roXon/hMmbK/2/ when i use container
How can i extract the date stored in database? Example this date is stored
Ok. calendar.get(Calendar.MONTH); returns the index of the current month. So for example if this
Trying to follow this example to make it work: http://weblogs.asp.net/kiyoshi/archive/2008/10/08/wcf-using-webhttpbinding-for-rest-services.aspx Here is my App.config
This example uses a StringWriter to hold the serialized data, then calling ToString() gives
this example below works when hover event is trigered and when its not, its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.