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

  • SEARCH
  • Home
  • 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 9239753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:03:40+00:00 2026-06-18T08:03:40+00:00

I have column values like A1,A20……..A10. When I do an order by, the values

  • 0

I have column values like A1,A20........A10. When I do an order by, the values are displayed as A1,A10, A2 and so on…

But, I want to display the columns in this format

A1
A2
A10
A20 and so on..

Can someone please tell me how do I achieve this sorting?

  • 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-06-18T08:03:41+00:00Added an answer on June 18, 2026 at 8:03 am

    if the pattern of your column is just A-Z + some numbers, you could sort with

    select id
      from your_table
     order by regexp_replace(id, '[0-9]', ''), 
              to_number(regexp_replace(upper(id), '[A-Z]', ''));
    

    regexp_replace(id, '[0-9]', ''),

    the above just keeps “A”s first, then “B” etc. you can remove that if you don’t want to do that.

    but if any row has any other non-numeric characters, the query would fail on invalid number.

    eg:

    SQL> select * from tester order by id;
    
    ID
    -----
    A1
    A10
    A2
    A3
    A4
    A5
    A6
    A7
    A8
    A9
    B1
    B10
    B2
    B3
    B4
    B5
    B6
    B7
    B8
    B9
    
    20 rows selected.
    
    SQL> select id from tester order by regexp_replace(id, '[0-9]', ''), to_number(regexp_replace(upper(id), '[A-Z]', ''));
    
    ID
    -----
    A1
    A2
    A3
    A4
    A5
    A6
    A7
    A8
    A9
    A10
    B1
    B2
    B3
    B4
    B5
    B6
    B7
    B8
    B9
    B10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have values like this in my column: /1/0/101.00_1234.jpg Now I want to replace
I have values like this in my amount column 323547.23700 12345643.34222 I want to
We have a column with values like this (USER.F1, USER.F2. USER.F3 ...) for regular
I have a column with values like this: 01709100011 I need to transform it
I have a column with a bunch of rows with values like this. ZIP
I have a column DECIMAL(9,6) i.e. it supports values like 999,123456. But when I
I have column with values like this: $30K - $50K How to extract lower
I have a column with values like: 1492966EMAIL1ABCDEFGHIJK12/22/2012 04:20:35 I want to replace the
I have column with varchar values like 022008 that I need to convert into
If I have table with a Date column called myDate , with values like

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.