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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:56:45+00:00 2026-06-06T00:56:45+00:00

My data in Oracle is something like this NAME | DEP_VALUE | ID_DEP Amy

  • 0

My data in Oracle is something like this

NAME | DEP_VALUE | ID_DEP

Amy     1         AA1234
Bob     2         BB4321
Clara   1         CC5678
Clara   2         CC7890
John    1         JJ6543
John    2         JJ7865
John    3         JJ7654
Tom     1         TT0987
Tom     2         TT6541
Tom     3         TT4087
Tom     4         TT3409

I need the data to be pulled in this fashion

NAME  | DEP_VALUE |  ID_DEP

Amy     1         AA1234
Bob     2         BB4321
Clara   1;2       CC5678;CC7890
John    1;2;3     JJ6543;JJ7865;JJ7654
Tom     1;2;3;4   TT0987;TT6541;TT4087;TT3409

My query is as follows

SELECT name,
   Rtrim(Xmlagg (Xmlelement (e, dep_value
                                || ';')).extract  ( '//text()' ), ','),
   Rtrim(Xmlagg (Xmlelement (e, id_dep
                                || ';')).extract  ( '//text()' ), ',')
FROM   (SELECT emp_name,
           dep.dep_value,
           dep.id_dep
    FROM   emp
           inner join dep
                   ON emp.name = dep.name
    WHERE  id_name IN (SELECT name
                       FROM   altname
                       WHERE  id_emp IN (SELECT id_emp
                                         FROM   cnames
                                         WHERE  emp_lvl LIKE '%GGG%')))
    GROUP  BY name,
      dep_value  

The result that is displayed is

NAME  | DEP_VALUE |  ID_DEP

Amy     1;         AA1234;
Bob     2;         BB4321;
Clara   1;         CC5678;
Clara   2;         CC7890;
John    1;         JJ6543;
John    2;         JJ7865;
John    3;         JJ7654;
Tom     1;         TT0987;
Tom     2;         TT6541;
Tom     3;         TT4087;
Tom     4;         TT3409;

How can I pull the data as in the 2nd table? What is the error in my sql query?

  • 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-06T00:56:48+00:00Added an answer on June 6, 2026 at 12:56 am

    It sounds like you want to GROUP BY name rather than GROUP BY name, dep_value

    SELECT name,
       Rtrim(Xmlagg (Xmlelement (e, dep_value
                                    || ';')).extract  ( '//text()' ), ';'),
       Rtrim(Xmlagg (Xmlelement (e, id_dep
                                    || ';')).extract  ( '//text()' ), ';')
    FROM   (SELECT emp_name,
               dep.dep_value,
               dep.id_dep
        FROM   emp
               inner join dep
                       ON emp.name = dep.name
        WHERE  id_name IN (SELECT name
                           FROM   altname
                           WHERE  id_emp IN (SELECT id_emp
                                             FROM   cnames
                                             WHERE  emp_lvl LIKE '%GGG%')))
        GROUP  BY name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Oracle table with data that looks like this: ID BATCH STATUS
I have a stored procedure that goes something like this (pseudo code) storedprocedure param1,
I have couple of statements, the pseudo code would look something like this: insert
I have a table in Oracle 10 that is defined like this: LOCATION HOUR
I have a legacy DB dump file which starts off something like this: ^C^@&D
I am trying to do something like this: Public Sub (ByVal boolTest As Boolean)
I have a query which is something like this SELECT t.category, tc.product, tc.sub-product, count(*)
This is the data that I would like to sort. AAAAAAAA 0.0.0.0 hs01.stuff.net BBBBBBBB
In Oracle, you can create a temp table using something like: CREATE GLOBAL TEMPORARY
DB: Oracle 11g Is there a way to do something like the following: INSERT

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.