Solved

Getting DISTINCT values using XMLAGG function

Posted on 2011-02-24
2
5,703 Views
Last Modified: 2012-05-11
Trying to obtain distinct values from the following line if SQL code:

rtrim (xmlagg (xmlelement (e, BRAND || ',')).extract ('//text()'), ',') Purchase_BRAND

0
Comment
Question by:globalwm2
2 Comments
 
LVL 73

Accepted Solution

by:
sdstuber earned 75 total points
ID: 34972532
wrap your query that returns the BRAND column in an inline view that returns distinct values

something like this...

select
rtrim (xmlagg (xmlelement (e, BRAND || ',')).extract ('//text()'), ',') Purchase_BRAND
from (select distinct brand from yourtable)

0
 

Author Closing Comment

by:globalwm2
ID: 35038838
I ran into issues when trying to perform a CTAS statement to a table. Ultimately has to use the .getclobval() statement and remove the RTRIM of the ',' to move on.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Cannot open form error 6 49
Access Query 4 34
Query question 4 30
Outer Query not returning data - SQL HELP 16 41
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now