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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:15:46+00:00 2026-06-09T19:15:46+00:00

I have two STUFF questions for this topic. First question is STUFF function in

  • 0

I have two STUFF questions for this topic.

First question is STUFF function in SQL Server. 2nd question is about the STUFF function in Oracle (8i).

Question 1: How can I remove the , from the column I want to stuff?

Example, given table:

ID      Country     Payment     Product
12345       USA     Cash        Red wine
12345       USA     Cash    
12345       USA     Cash

Using this script, it produces:

select distinct Country, Payment,
stuff(isnull((select ', ' + x.Product from #temp x where x.ID = t.ID
group by x.Product for xml path ('')), ''), 1, 2, '') as Product


ID      Country     Payment     Product
12345   USA         Cash       , Red wine

How can I remove result to show just Red wine only (remove the comma (,)?

PLEASE NOTE: I did not write this STUFF function. It is written by someone named OMG Ponies.

Question 2: Same as question 1 but the syntax is in Oracle:

select distinct ID, Country, Payment, WM_CONCAT(Product) AS Products
from
(
select distinct ID, Country, Payment, Product
from temp table
)x
group by ID, Country, Payment

I would like my result to show just Red wine only (remove the comma (,).

  • 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-09T19:15:48+00:00Added an answer on June 9, 2026 at 7:15 pm

    Question 1:
    As far as the SQL Server part of the answer it looks like you have empty strings in your Product field – they are not nulls if there is not one. So you can use the following. I added the line and (product != '' and product is not null) to your Stuff() part and it will remove the extra comma:

    select distinct Country, Payment,
        stuff(isnull((select ', ' + x.Product 
                        from test x 
                        where x.ID = t.ID 
                          and (product != '' and product is not null)
                        group by x.Product for xml path ('')), ''), 1, 2, '') as Product
    from test t
    

    See SQL Fiddle with Demo

    Question 2: I do not have access to an Oracle 8i version but I am going to guess that if you exclude the values with the empty string the comma will disappear.

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

Sidebar

Related Questions

I have a question about regex/Python. Sorry if this topic has been discussed millions
I read all the other questions about this, but i can't understand why there
I'm aware of these two questions which explain why I can't have a protected/private
Two questions about the Lock() construct in .net First, I am aware that if
I have two tables which have some transactional stuff stored in them. There will
I have two files client.php and server.php. The client file send a HTTP request
I have two columns say Main and Sub . (they can be of same
Similar questions have been asked before, but I can't find the specific details I'm
I have an ANSI C program comprising two files. The first file contains the
So .... There are obviously many questions that all have been asked about Singletons,

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.