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 8577831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:14:52+00:00 2026-06-11T20:14:52+00:00

I am having a sorting issue with oracle 10g. Not sure if it is

  • 0

I am having a sorting issue with oracle 10g. Not sure if it is specific to 10g or not.

I have the following table:

ID  NAME
 1  A.1
 2  A.3
 3  A.4
 4  A.5
 5  A.2
 6  A.5.1
 7  A.5.2
 8  A.5.10
 9  A.5.10.1
10  A.5.3

Performing the generic SELECT NAME FROM table_name ORDER BY 1 produces:

A.1
A.2
A.3
A.4
A.5
A.5.1
A.5.10
A.5.10.1
A.5.2
A.5.3

I would like it to sort correctly when those sections have numbers greater than 9, like so:

A.1
A.2
A.3
A.4
A.5
A.5.1
A.5.2
A.5.3
A.5.10
A.5.10.1

I have way more number entries than this with varying lengths and many sections with number segments greater than 10. I was trying to mess around with regexp_replace() in the order by clause but have had no luck. Any help would be greatly appreciated.

  • 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-11T20:14:53+00:00Added an answer on June 11, 2026 at 8:14 pm

    Try this

    WITH t AS
    (
      SELECT id,name,
      xmltype('<r><c>' ||replace(NAME, '.', '</c><c>')||'</c></r>') AS xmlname
      FROM table1
    )
    
    SELECT name ,id
    FROM t
    ORDER BY lpad(extract(xmlname,'//c[1]/text()').getstringval(), 5, '0')
    ||lpad(extract(xmlname,'//c[2]/text()').getstringval(), 5, '0')
    ||lpad(extract(xmlname,'//c[3]/text()').getstringval(), 5, '0')
    ||lpad(extract(xmlname,'//c[4]/text()').getstringval(), 5, '0')
    

    Here is a fiddle

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

Sidebar

Related Questions

I'm having an issue I've been fighting for a few hours, and have not
Hey, I'm having a sorting issue. I have the rows: 32 16 8 semifinals
I am having a difficult time sorting through this PHP/MySQL issue. Let me show
I'm having an issue with sorting a list that contains a dict. Currently I
I have a query hitting EF4 using STEs and I'm having an issue with
I have an issue with having a asp.net Grid View loaded into a div
I'm having trouble sorting a single-column table in Rails. Each row represents a single
I'm having a small issue with sorting the data returned from a query, with
I'm having a issue sorting an arraylist of custom objects by a string field.
I am having an issue on Sorting a ListBox with a dropdown. The dropdown

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.