Home » SQL & PL/SQL » SQL & PL/SQL » comma separated values (10.2.0.2.0)
comma separated values [message #391648] |
Thu, 12 March 2009 16:01 |
varunvir
Messages: 389 Registered: November 2007
|
Senior Member |
|
|
Hi Experts,
I am executing one queryas:-
SELECT d.doc_id,
e.attribute_value
FROM ct_bhi_document d,
lt_bhi_doc_attribute e
WHERE d.oid (+) = e.oid;
The results of this query are:-
UID163067 Agriculture
UID163067 Australia
UID163068 English
UID163068 crop protection
How can I get the following results:-
UID163067 Agriculture,Australia
UID163068 English,crop protection
Regards,
Varun Punj,
|
|
|
|
|
|
|
|
|
Re: comma separated values [message #392351 is a reply to message #392185] |
Tue, 17 March 2009 10:59 |
varunvir
Messages: 389 Registered: November 2007
|
Senior Member |
|
|
Hi Ashoka,
I have generated the following query:-
SELECT docs.doc_id,
child.hierachy
FROM (SELECT ta.oid,
Max(Decode(val_number,1,ta.attribute_name,
NULL))
||Max(Decode(val_number,2,','
||ta.attribute_name,
NULL))
||Max(Decode(val_number,3,','
||ta.attribute_name,
NULL))
||Max(Decode(val_number,4,','
||ta.attribute_name,
NULL))
||Max(Decode(val_number,5,','
||ta.attribute_name,
NULL))
||Max(Decode(val_number,6,','
||ta.attribute_name,
NULL))
||Max(Decode(val_number,7,','
||ta.attribute_name,
NULL))
||Max(Decode(val_number,8,','
||ta.attribute_name,
NULL))
||Max(Decode(val_number,9,','
||ta.attribute_name,
NULL))
||Max(Decode(val_number,10,','
||ta.attribute_name,
NULL))
||Max(Decode(val_number,11,','
||ta.attribute_name,
NULL))
||Max(Decode(val_number,12,','
||ta.attribute_name,
NULL))
||Max(Decode(val_number,13,','
||ta.attribute_name,
NULL))
||Max(Decode(val_number,14,','
||ta.attribute_name,
NULL)) AS hierachy
FROM (SELECT oid,
Row_number()
OVER(PARTITION BY oid ORDER BY attribute_name) AS val_number,
attribute_name
FROM (SELECT DISTINCT ta.attribute_name,
ta.oid
FROM lt_bhi_doc_attribute ta)) ta
GROUP BY ta.oid
ORDER BY ta.oid) child,
ct_bhi_document docs
WHERE docs.oid = child.oid;
Regards,
Varun Punj,
|
|
|
Goto Forum:
Current Time: Sun Dec 08 18:57:32 CST 2024
|