Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

distinct in oracle xmlagg

Posted on 2011-02-24
3
3,974 Views
Last Modified: 2012-05-11
Experts.. I have a query which is below

 select rtrim(EXTRACT(XMLAGG (XMLELEMENT("s",a.src_id|| ',' )), '/s/text()').getstringval())
        into v_src_id_list
        from cfs a, cdr b
        where b.emp_oid = 235
        and b.enty_id= a.enty_id;

This is getting the list but some of the elements in the list are duplicates. for ex: when I print out the v_src_id_list I have 1,2,3,3,4,4,5 in it.

Is there any way to eliminate the duplicates in this list?
0
Comment
Question by:chickanna
3 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 250 total points
ID: 34973670
Check out:
http://www.experts-exchange.com/Database/Oracle/Q_26845549.html


Try this:
select rtrim(EXTRACT(XMLAGG (XMLELEMENT("s",src_id|| ',' )), '/s/text()').getstringval())
        into v_src_id_list
        from ( select distinct a.src_id from cfs a, cdr b
        where b.emp_oid = 235
        and b.enty_id= a.enty_id);

0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 250 total points
ID: 34973673
query distinct values first then aggregate


 select rtrim(EXTRACT(XMLAGG (XMLELEMENT("s",src_id|| ',' )), '/s/text()').getstringval())
        into v_src_id_list
from
(select distinct a.src_id
        from cfs a, cdr b
        where b.emp_oid = 235
        and b.enty_id= a.enty_id)

0
 

Author Closing Comment

by:chickanna
ID: 34973785
thank you experts.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

829 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