Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Distinct string statement
DA Morgan wrote:
> Marina S. wrote: >
> > > Given that this is homework you will need to do a lot more than this > to obtain help. Show us your work and we will hint you toward the > solution. > > PS: The Oracle version is essential for help.
Well, I wouldn't want to do the OP's presumed homework ;-) but I got to thinking how simple this would be in Perl, and not being a PL/SQL jockey, I wondered how to do it in that language.
My very first search hit (left as an exercise to the alleged student) got me to a pair of nice PL/SQL functions (SPLIT and JOIN) written by Scott Stephens of Oracle. As he says, "Many scripting languages, such as Perl and Python, provide functions that do this with their own language-specific list of values; so it's surprising that, as of yet, this functionality isn't a standard part of SQL functions."
select * from t;
ID SYMBOL
---------- -------------------- 11 abc,bbc,abf,cde 22 rda,abc,aig 33 ibm,aig,sun 55 aig,klm,suk,sun 23 bbc,kln,sun,adf select join(cursor( select distinct column_value from table(split(join(cursor(select symbol from t))))))from dual;
JOIN(CURSOR(SELECTDISTINCTCOLUMN_VALUEFROMTABLE(SPLIT(JOIN(CURSOR(SELECTSYMBOLFROMT))))))
This won't quite meet the OP's requirements as the result is sorted normally not topologically.
-Mark Bole Received on Mon Feb 21 2005 - 17:39:26 CST