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

The Archive Base Latest Questions

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

I have scenario where i want the invoice numbers from two tables in csv

  • 0

I have scenario where i want the invoice numbers from two tables in csv list. I could accomplish this using Stuff as below:

SELECT
   sopnumbe
  ,custname 
  ,Invoices = 
        STUFF((SELECT DISTINCT ', '+ RTRIM(a.sopnumbe)+', '+ RTRIM(B.sopnumbe)
               FROM 
                  SOP10100  a
                  fULL OUTER JOIN 
                  SOP30200 B
                  ON a.ORIGNUMB =B.ORIGNUMB
               WHERE a.ORIGNUMB =@ordernumb
               FOR XML PATH('')) , 1 , 1 , '' )
FROM SOP10100
WHERE
    SOPNUMBE = @ordernumb

The above query produces right results except for the repetitive invoice numbers in the list. Is there any other way to accomplish this?


if the result of simple outer join query is:

INV1527157              INV1523836        
INV1527157              INV1526475  


the result of stuff query:

K08081383206      BACHELOR CONTROLS INC    INV1527157, INV1523836, INV1527157, INV1526475

INV1527157 gets repeated, i want to get rid of repetition.

  • 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-04T18:55:50+00:00Added an answer on June 4, 2026 at 6:55 pm

    You may want to try UNION the results together from A and B, rather than a full outer join:

    SELECT ', '+ RTRIM(sopnumbe)
    FROM (SELECT sopnumbe FROM SOP10100 a WHERE a.ORIGNUMB = @ordernumb
          UNION
          SELECT sopnumbe FROM SOP30200 b WHERE b.ORIGNUMB = @ordernumb
    ) RESULT
    

    This will return only the distinct results from both subqueries.

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

Sidebar

Related Questions

So I have this scenario <div id=editor contenteditable=true> <div id=list>Hello</div> </div> I want to
I have a scenario where I want to be able to SELECT rows from
I have this scenario. I want group on Country and Category. A store can
I have a scenario where I have a list of classes, and I want
I have this scenario where I want to display the xml which is coming
I have this scenario with GIT: I want to do something with a specific
I have this scenario where I want to share the column size among all
I have a scenario where i want to get documentation files from Documentation folder
We have a scenario where we want to display a list of items and
I have a scenario where I want to call one TFS build from another,

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.