FROM
A_EMPLOYEEMASTER A, TCR B , DESIGNATION C
WHERE
A.EMPLOYEEID = B.EMPLOYEEID(+)
AND DESIGNATION = DESIGNATION(+)
AND STATUS = ‘ACTIVE’
AND REVEIVEDDATE = ‘02-AUG-2010’
I’ll just reference a similar email I answered recently about how to
concatenate a column.
Basically the easiest way not knowing the number of rows to concatenate
you can simply create a function that returns the concatenated data like
below.
So for your query replace the date/year column with the function call
passing in the EMPLOYEEID to retrieve the years.
If you need more help let us know.
Ed
[TeamT]
-------- Original Message --------
Subject: Re: [toad] concatenation in toad challenge.
Date: Tue, 13 Jul 2010 12:55:04 -0400
[ Attachment(s) from Erwin Rollauer included below]
I have attached a file that uses CONNECT BY to do this without requiring a
function.
What you are trying to do is NOT NORMAL SQL so you have to use major ingenuity
such as the Function that TRYON suggested, the CONNECT BY that I am suggesting.
Not quite the only real way. The last time this question came through (just a
couple weeks ago if I remember correctly) there was a very nice solution
provided. It can be seen in the following example.
Notes:
The credit for the solution lies with the original author, I simply kept a
sample of it in case I ever needed it.
Put the code in the formatter first, knowing Yahoo it’ll wipe out all
the extra white space.
The “with” portion is strictly there to create a temporary
“table like set” of the target data
WITH order_details AS (SELECT 1 order_no,
'ABC' item_code
FROM DUAL
UNION ALL
SELECT 1 order_no,
'DEF' item_code
FROM DUAL
UNION ALL
SELECT 1 order_no,
'GHI' item_code
FROM DUAL
UNION ALL
SELECT 2 order_no,
'JKL' item_code
FROM DUAL
UNION ALL
SELECT 2 order_no,
'MNO' item_code
FROM DUAL
UNION ALL
SELECT 3 order_no,
'PQR' item_code
FROM DUAL)
SELECT order_no,
SUBSTR( SYS_CONNECT_BY_PATH( item_code,
','
),
2
)
item_codes
FROM ( SELECT order_no,
item_code,
ROW_NUMBER( ) OVER (PARTITION BY order_no ORDER BY item_code) rn