hazelsisson
Programmer
Hello,
I have a query that gathers data from 3 tables. Some of the data is duplicated, like this:
TITLE ORDER NO FIRM USED
----- -------- ---------
June job 191 firm1
June job 192 firm2
(It's a similar situation to thread759-615918).
I would like the output to be something like this, so that I can show all the information in one table row:
TITLE ORDER NO FIRM USED
----- -------- ---------
June job 191, 192 firm1, firm2
Would it be possible to build this into the query somehow, possibly using the decode function as I saw in the thread I mentioned before?
I had a go myself, and got this far:
Which produces this output:
TITLE ORDER NO FIRM USED
----- -------- ---------
June job Two Two
So now I just need to get it to display the values from the table, rather than a count.
Thanks for any ideas/advice.
Hazel
I have a query that gathers data from 3 tables. Some of the data is duplicated, like this:
TITLE ORDER NO FIRM USED
----- -------- ---------
June job 191 firm1
June job 192 firm2
(It's a similar situation to thread759-615918).
I would like the output to be something like this, so that I can show all the information in one table row:
TITLE ORDER NO FIRM USED
----- -------- ---------
June job 191, 192 firm1, firm2
Would it be possible to build this into the query somehow, possibly using the decode function as I saw in the thread I mentioned before?
I had a go myself, and got this far:
Code:
select worksheets.TITLE,
decode(count(orders.ORDER_NO),0,'None',1,'One',2,'Two','default') orderNuumber,
decode(count(companies.NAME),0,'None',1,'One',2,'Two','default') compName
from worksheets, orders, outwork_company, companies
where worksheets.JOB_NO = orders.JOB_NO(+)
and worksheets.ARCHIVE = 'N'
and orders.OUTWORK_ID = outwork_company.OUTWORK_ID(+)
and outwork_company.used(+) = 'Y'
and outwork_company.COMPANY_ID = companies.COMPANY_ID(+)
group by worksheets.TITLE
order by worksheets.TITLE
Which produces this output:
TITLE ORDER NO FIRM USED
----- -------- ---------
June job Two Two
So now I just need to get it to display the values from the table, rather than a count.
Thanks for any ideas/advice.
Hazel