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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:49:29+00:00 2026-06-04T05:49:29+00:00

I have a column with values as below: BOOK # ,7,8 BOOK # ,2

  • 0

I have a column with values as below:

BOOK # ,7,8
BOOK # ,2
BOOK # ,13,14

I am generating above column with complex xml aggregate function as below:

SELECT 
CONCAT('BOOK # ',XMLSERIALIZE(XMLAGG(XMLTEXT(CONCAT(',', SUBSTR(TRIM(TEMP.BOOK_NUM),    
LOCATE('.',TEMP.BOOK_NUM)+1)))) AS VARCHAR(1024 )))
FROM TEMP 
GROUP BY BOOK_ID

Temp.book_num is of type 123.2, 123.4 in two different rows. So book_id 123 will have two books 2, 4. Thus to extract 2 and 4 out of two rows of same book_id, I had to write above query.

As clear there is an extra ‘,’ comma coming after the words ‘BOOK #’ which is redundant and unrequired.

I am not able to modify above query to remove it.

Is there any way possible to remove the first occurrence of a character (comma here) from a column value which could be accomodated in the query above ?

My output should be:

BOOK # 7,8
BOOK # 2
BOOK # 13,14

Thanks for reading!

  • 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-04T05:49:30+00:00Added an answer on June 4, 2026 at 5:49 am

    Although the wording is almost identical, it’s a lot easier to remove the first character than it is to remove the first occurrence of a specific character. Fortunately, just removing the first character will solve your problem. You can do that by stuffing your XMLSERIALIZE() expression into a SUBSTR() call like this:

    CONCAT('BOOK # ',
        SUBSTR(
            XMLSERIALIZE(XMLAGG(XMLTEXT(CONCAT(',', SUBSTR(TRIM(TEMP.BOOK_NUM),  
               LOCATE('.',TEMP.BOOK_NUM)+1)))) AS VARCHAR(1024))
           ,2
        )
    )
    

    Thanks to Serge Rielau for posting this trick in his blog.

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

Sidebar

Related Questions

I have a multi-table SELECT query which compares column values with itself like below:
I have to select checkboxes besed on group column values. If you see below
I have two columns X and Y where the values could be as below:
I have column with varchar values like 022008 that I need to convert into
How can I find all column values in a column which have trailing spaces?
I have many tables that use Lookup/Enum references for most of their column values.
Is it possible to edit computed-column values? I have a computed-col in my table,
I have a column StudentData ( varchar ) Sample values: Not regular 90 15.2
I have a table with a column whose values come from an Enumeration. I
i have a large mysql database table in which one column contains values ranging

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.