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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:57:15+00:00 2026-05-12T10:57:15+00:00

How would I do in a SELECT query to reverse this path : z/y/x

  • 0

How would I do in a SELECT query to reverse this path :

z/y/x 

for

x/y/z

where / is the delimiter
and where there can be many delimiters in a single line

ex: select (... z/y/x/w/v/u ...) reversed_path from ...
  • 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-12T10:57:15+00:00Added an answer on May 12, 2026 at 10:57 am

    The simplest way would probably be to write a stored pl/sql function, however it can be done with SQL (Oracle) alone.

    This will decompose the path in subpath:

    SQL> variable path varchar2(4000);
    SQL> exec :path := 'a/b/c/def';
    
    PL/SQL procedure successfully completed
    SQL> SELECT regexp_substr(:path, '[^/]+', 1, ROWNUM) sub_path, ROWNUM rk
      2    FROM dual
      3  CONNECT BY LEVEL <= length(regexp_replace(:path, '[^/]', '')) + 1;
    
    SUB_P RK
    ----- --
    a      1
    b      2
    c      3
    def    4
    

    We then recompose the reversed path with the sys_connect_by_path:

    SQL> SELECT MAX(sys_connect_by_path(sub_path, '/')) reversed_path
      2    FROM (SELECT regexp_substr(:path, '[^/]+', 1, ROWNUM) sub_path,
      3                 ROWNUM rk
      4             FROM dual
      5           CONNECT BY LEVEL <= length(regexp_replace(:path, '[^/]', '')) + 1)
      6  CONNECT BY PRIOR rk = rk + 1
      7   START WITH rk = length(regexp_replace(:path, '[^/]', '')) + 1;
    
    REVERSED_PATH
    -------------
    /def/c/b/a
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would I write a SQLite query to select all records from a specific
Which query would run faster? SELECT * FROM topic_info LEFT JOIN topic_data ON topic_info.id
I'm using SQL Server 2005. The query would look like this Select col1, col2,
I would like to export a ad hoc Select query result sets from SQL
I run this query: SELECT u.user_id, u.fname, u.lname, n.title, n.news_id, n.post, n.zip, z.city,z.state_abbr FROM
Short version: How do I write this query in squeel? SELECT OneTable.*, my_count FROM
I would like to delete all the rows found by that query: SELECT cart_abandon.*
How would I execute a query equivalent to select top 10 in couch db?
I would like to do a query like next: SELECT table_name, column_name, data_type, is_nullable,
How would I create the equivalent Linq To Objects query? SELECT MIN(CASE WHEN p.type

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.