From: webtourist on
> SELECT deptno,
2 substr(REPLACE(REPLACE(xmlagg(xmlelement("x", job) ORDER BY
job), '</x>'), '<x>', ' '), 2) job_list
3 FROM emp
4 GROUP BY deptno
5 ORDER BY deptno
6/

DEPTNO JOB_LIST
------ ----------------------------------------------------
10 CLERK MANAGER PRESIDENT
20 ANALYST ANALYST CLERK CLERK MANAGER
30 CLERK MANAGER SALESMAN SALESMAN SALESMAN SALESMAN



How can I get result like this: (distinct names in "job_list") ?


DEPTNO JOB_LIST
------ ----------------------------------------------------
10 CLERK MANAGER PRESIDENT
20 ANALYST CLERK MANAGER
30 CLERK MANAGER SALESMAN
From: Maxim Demenko on
On 12.03.2010 22:58, webtourist wrote:
>> SELECT deptno,
> 2 substr(REPLACE(REPLACE(xmlagg(xmlelement("x", job) ORDER BY
> job), '</x>'),'<x>', ' '), 2) job_list
> 3 FROM emp
> 4 GROUP BY deptno
> 5 ORDER BY deptno
> 6/
>
> DEPTNO JOB_LIST
> ------ ----------------------------------------------------
> 10 CLERK MANAGER PRESIDENT
> 20 ANALYST ANALYST CLERK CLERK MANAGER
> 30 CLERK MANAGER SALESMAN SALESMAN SALESMAN SALESMAN
>
>
>
> How can I get result like this: (distinct names in "job_list") ?
>
>
> DEPTNO JOB_LIST
> ------ ----------------------------------------------------
> 10 CLERK MANAGER PRESIDENT
> 20 ANALYST CLERK MANAGER
> 30 CLERK MANAGER SALESMAN

Silly approach:

select deptno,
substr(replace(replace(xmlagg(xmlelement("x", job) order by job),
'</x>'), '<x>', ' '), 2) job_list
from (select unique deptno,job from emp) emp
group by deptno
order by deptno

?

Best regards

Maxim
From: John Hurley on
On Mar 12, 4:58 pm, webtourist <webtour...(a)gmail.com> wrote:

snip

> How can I get result like this: (distinct names in "job_list") ?
>
> DEPTNO JOB_LIST
> ------ ----------------------------------------------------
>     10 CLERK MANAGER PRESIDENT
>     20 ANALYST CLERK MANAGER
>     30 CLERK MANAGER SALESMAN

Are you running 7.3.4?
From: Shakespeare on
Op 13-3-2010 0:42, John Hurley schreef:
> On Mar 12, 4:58 pm, webtourist<webtour...(a)gmail.com> wrote:
>
> snip
>
>> How can I get result like this: (distinct names in "job_list") ?
>>
>> DEPTNO JOB_LIST
>> ------ ----------------------------------------------------
>> 10 CLERK MANAGER PRESIDENT
>> 20 ANALYST CLERK MANAGER
>> 30 CLERK MANAGER SALESMAN
>
> Are you running 7.3.4?

Was xmlagg in that version?

Shakespeare
From: webtourist on
On Mar 12, 7:42 pm, John Hurley <johnbhur...(a)sbcglobal.net> wrote:
> Are you running 7.3.4?


no, it's too advanced for us....we're on 10gR2