I have this SQL:
Code:
[blue]
SELECT MYPROJNO.PSPROJNO_TYPE_OF_PROJECT [/blue]|| ' ' ||
( select substr(max(sys_connect_by_path(PSDSNO_DESIGNNUMBER,',')),2)
from
(select PSDSNO_PROJECTNUMBER, PSDSNO_DESIGNNUMBER, row_number()
over (partition by PSDSNO_PROJECTNUMBER order by PSDSNO_DESIGNNUMBER) rn
from S4111000.PSDSNO_INFORMATION
WHERE PSDSNO_PROJECTNUMBER =([b]'BRF-006-1(114)--38-78'[/b]))
start with rn = 1
connect by prior rn = rn -1
and prior PSDSNO_PROJECTNUMBER = PSDSNO_PROJECTNUMBER)
[blue]
AS " ", [b]MYLET.PSLET_PROJECTNUMBER AS "Project Number", [/b]
MYSTATUS.PSSTATUS_STATUS AS "Status",
MYLET.PSLET_ROAD_SQUAD_FULLNAME AS "Assigned To",
MYWKCODE.PSWKCODE_DESCRIPTION AS "Type of Work",
TO_CHAR(MYLET.PSLET_PLANTURNINDATE, 'MM/DD/YYYY') AS "Plan Turn-In",
TO_CHAR(MYLET.PSLET_CONTRACTLETDATE, 'MM/DD/YYYY') AS "Letting Date",
'$' || MYLET.PSLET_CURFIVEYREST AS "Program Est",
'$' || MYLET.PSLET_CURDEVELOPEST AS "Develop Est",
MYLET.PSLET_AWARDEDCONTRACT AS "Awarded",
MYLET.PSLET_PAID_TO_DATE AS "Paid To Date",
MYLET.PSLET_FINALCONTRACT AS "Final Project $"
FROM S4111000.PSLET_INFORMATION MYLET INNER JOIN
S4111000.PSPROJNO_INFORMATION MYPROJNO
ON MYLET.PSLET_PROJECTID = MYPROJNO.PSPROJNO_PROJECTID AND
MYLET.PSLET_PROJECTNUMBER = MYPROJNO.PSPROJNO_PROJECTNUMBER INNER JOIN
S4111000.PSSTATUS MYSTATUS ON MYLET.PSLET_DELBYTE = MYSTATUS.PSSTATUS_DELBYTE
INNER JOIN
S4111000.PSWKCODE_INFORMATION MYWKCODE ON
MYLET.PSLET_WORKCODE1 = MYWKCODE.PSWKCODE_WORKCODE4
WHERE (MYLET.PSLET_PROJECTNAME = '98-36-002-010-04')
AND (NOT (MYPROJNO.PSPROJNO_PROJECT_RANK = 12 OR
MYPROJNO.PSPROJNO_PROJECT_RANK = 13))
ORDER BY "Letting Date", "Plan Turn-In", "Project Number"[/blue]
If I just run BLACK part inside () it runs fine.
I can run this whole SQL fine, but I would like to replace hardcoded (bolded) Project Number 'BRF-006-1(114)--38-78' with the field from BLUE part (MYLET.PSLET_PROJECTNUMBER AS "Project Number") and that's where the problem is.
How can I read the Project Number from my BLUE Sql inside my BLACK Select statement?
Anybody has any ideas?
Have fun.
---- Andy