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

  • Home
  • SEARCH
  • 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 6586831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:50:28+00:00 2026-05-25T16:50:28+00:00

I have this statement that combines multiple rows into one and then outputs it

  • 0

I have this statement that combines multiple rows into one and then outputs it in the way I need the data:

 SELECT COURSES_ID, REQUISITE_TYPE_TITLE
            , RTRIM
           ( xmlagg (xmlelement (c, CONDITION_TITLE || '' || REQ_TEXT || ''  ) order by   ORDER_NUM).extract ('//text()')
           , ',' ) AS REQTexts
    FROM   COS_REQUISITES
    WHERE COURSES_ID = '1175'
    AND REQUISITE_TYPE_TITLE !=  'Corequisite'
    GROUP BY COURSES_ID, REQUISITE_TYPE_TITLE;

Result:

╔═══════════╦════════════╦═════════════════════════════════════╦═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ ORDER_NUM ║ COURSES_ID ║        REQUISITE_TYPE_TITLE         ║                                                                                                                                                           REQ_TEXT                                                                                                                                                            ║
╠═══════════╬════════════╬═════════════════════════════════════╬═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║         1 ║       1175 ║ Limitation on Enrollment            ║   With minimum grade of "C"                                                                                                                                                                                                                                                                                         ║
║         2 ║       1175 ║ Advisory on Recommended Preparation ║ MATH 200 or equivalent college course with "C" or better  or equivalent college course with "C" or better or MATH 205 or equivalent college course with "C" or better or   or equivalent college course with "C" or better  or equivalent college course with "C" or better ║
╚═══════════╩════════════╩═════════════════════════════════════╩═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

Structure:

╔═══════════╦════════════╦═══════════╦═════════════════════════════════════╦══════════════════════════════════════════════════════════╗
║ ORDER_NUM ║ COURSES_ID ║ CONDITION ║        REQUISITE_TYPE_TITLE         ║                         REQ_TEXT                         ║
╠═══════════╬════════════╬═══════════╬═════════════════════════════════════╬══════════════════════════════════════════════════════════╣
║      1164 ║       1175 ║           ║ Advisory on Recommended Preparation ║ MATH 200 or equivalent college course with "C" or better ║
║      1165 ║       1175 ║           ║ Advisory on Recommended Preparation ║   or equivalent college course with "C" or better        ║
║      1166 ║       1175 ║  or       ║ Advisory on Recommended Preparation ║ MATH 205 or equivalent college course with "C" or better ║
║      1167 ║       1175 ║  or       ║ Advisory on Recommended Preparation ║   or equivalent college course with "C" or better        ║
║      1168 ║       1175 ║           ║ Advisory on Recommended Preparation ║   or equivalent college course with "C" or better        ║
║      1169 ║       1175 ║           ║ Limitation on Enrollment            ║   With minimum grade of "C"                              ║
╚═══════════╩════════════╩═══════════╩═════════════════════════════════════╩══════════════════════════════════════════════════════════╝

Wanted result:

╔═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ Advisory on Recommended Preparation MATH 200 or equivalent college course with "C" or better  or equivalent college course with "C" or better or MATH 205 or equivalent college course with "C" or better or equivalent college course with "C" or better  or equivalent college course with "C" or better Limitation on Enrollment With minimum grade of "C" ║
╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

I’m trying to avoid having to put this to a temp table or multiple views that would output this into one section.

I know it has bad data but I was told Garbage In, Garbage Out. Any help would be greatly appreciated.

Even with LISTAGG which doesn’t allow for distinct as far as I can tell:

SELECT COURSES_ID, LISTAGG(REQUISITE_TYPE_TITLE || ‘ ‘ ||
CONDITION_TITLE || ‘ ‘ || REQ_TEXT, ‘ ‘) WITHIN GROUP (ORDER BY
ORDER_NUM) AS Title FROM COS_REQUISITES WHERE COURSES_ID = ‘1175’
GROUP BY COURSES_ID;

Result:

╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║                                                                                                                                                                                                                                                             TITLE                                                                                                                                                                                                                                                              ║
╠════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║ Advisory on Recommended Preparation  MATH 200 or equivalent college course with "C" or better Advisory on Recommended Preparation    or equivalent college course with "C" or better Advisory on Recommended Preparation  or  MATH 205 or equivalent college course with "C" or better Advisory on Recommended Preparation  or    or equivalent college course with "C" or better Advisory on Recommended Preparation    or equivalent college course with "C" or better Limitation on Enrollment    With minimum grade of "C" ║
╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

Notice the REQUISITE_TYPE_TITLE repeats, I only want it to show up once like the wanted result. I can’t modify the table to have them null due to this is a table being loaded dynamically and updated by someone else daily.

  • 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-25T16:50:29+00:00Added an answer on May 25, 2026 at 4:50 pm

    a bit messy but should yield what you asked for

    SELECT 
    COURSES_ID, 
    RTRIM ( xmlagg (xmlelement (c, REQUISITE_TYPE_TITLE || '' || REQTexts || ''  ) order by   mino).extract ('//text()'), ',' ) AS REQTexts
    FROM
    (
    SELECT 
    COURSES_ID, REQUISITE_TYPE_TITLE, MIN (ORDER_NUM) mino, 
    RTRIM ( xmlagg (xmlelement (c, CONDITION_TITLE || '' || REQ_TEXT || ''  ) order by   ORDER_NUM).extract ('//text()') , ',' ) AS REQTexts
    FROM COS_REQUISITES
    WHERE COURSES_ID = '1175'
    AND REQUISITE_TYPE_TITLE !=  'Corequisite'
    GROUP BY COURSES_ID, REQUISITE_TYPE_TITLE
    ) 
    GROUP BY COURSES_ID;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a statement similar to this that I need to run in Linq.
I need to know of a way to combine multiple SELECT statements in one
I have a stored procedure that uses this select statement: SELECT dbo.VendorProgram.id, dbo.VendorProgram.CODE, dbo.Programs.ProgramName
I have this if statement that tests for the 2 conditions below. The second
I have this query statement and want to only get records that has a
I have LINQ statement that looks like this: return ( from c in customers
I have an if statement that needs to look like this: UPDATE $(input#textbox).keypress(function(e){ key==e.which;
I have a sql statement that uses Difference => http://msdn.microsoft.com/en-us/library/ms188753.aspx I do this in
I have the a simple LinqToSQL statement that is not working. Something Like this:
Greetings, Here is my problem. I need to get data from multiple rows and

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.