irodov
asked on
Oracle SQL Query Question -- Very urgent
Hi All,
Would appreciate any urgent help here pls..
I have a 2 queries..
First query as below:
SELECT
BDVU.EQUIP_INST.DESCR, CIRC_PATH_INST.CIRC_PATH_H UM_ID
FROM
BDVU.CARD_INST, BDVU.CIRC_PATH_INST, BDVU.EQUIP_INST, BDVU.EPA,
BDVU.CIRC_PATH_ELEMENT, BDVU.SITE_INST
WHERE
BDVU.EQUIP_INST.TYPE = 'IDT'
AND BDVU.EQUIP_INST.EQUIP_INST _ID = BDVU.CARD_INST.EQUIP_INST_ ID
AND BDVU.CARD_INST.CARD_INST_I D = BDVU.EPA.CARD_INST_ID
AND BDVU.CIRC_PATH_ELEMENT.POR T_INST_ID = BDVU.EPA.PORT_INST_ID
AND BDVU.CIRC_PATH_ELEMENT.CIR C_PATH_INS T_ID =
BDVU.CIRC_PATH_INST.CIRC_P ATH_INST_I D
AND BDVU.SITE_INST.SITE_INST_I D = BDVU.EQUIP_INST.SITE_INST_ ID
AND BDVU.CIRC_PATH_INST.CIRC_P ATH_HUM_ID = '6172273678'
gives 1 row as :
DESCR CIRC_PATH_HUM_ID
IDT 103 BOWDOIN 6172273678
Second query:::
select
BDVU.SITE_INST.SITE_HUM_ID , CIRC_PATH_INST.CIRC_PATH_H UM_ID
from
BDVU.CARD_INST, BDVU.CIRC_PATH_INST, BDVU.EQUIP_INST, BDVU.EPA,
BDVU.CIRC_PATH_ELEMENT, BDVU.SITE_INST
WHERE
BDVU.EQUIP_INST.TYPE = 'POT BAY'
AND BDVU.EQUIP_INST.EQUIP_INST _ID = BDVU.CARD_INST.EQUIP_INST_ ID
AND BDVU.CARD_INST.CARD_INST_I D = BDVU.EPA.CARD_INST_ID
AND BDVU.CIRC_PATH_ELEMENT.POR T_INST_ID = BDVU.EPA.PORT_INST_ID
AND BDVU.CIRC_PATH_ELEMENT.CIR C_PATH_INS T_ID =
BDVU.CIRC_PATH_INST.CIRC_P ATH_INST_I D
AND BDVU.CIRC_PATH_INST.CIRC_P ATH_HUM_ID = '6172273678'
AND BDVU.SITE_INST.SITE_INST_I D = BDVU.EQUIP_INST.SITE_INST_ ID
gives 1 row as below..
SITE_HUM_ID CIRC_PATH_HUM_ID
BSTNMABOHBF 6172273678
I want to union them to display result as below
SITE_HUM_ID Descr CIRC_PATH_HUM_ID
BSTNMABOHBF IDT 103 BOWDOIN 6172273678
But, please note that ...
I want to remove hard-coded CIRC_PATH_INST.CIRC_PATH_H UM_ID from both queries...
and want to make such that -- for each value of CIRC_PATH_INST.CIRC_PATH_H UM_ID (%)..
it should execute the top query first -- and then will execute the bottom query for same
CIRC_PATH_INST.CIRC_PATH_H UM_ID and then show the results as shown in the above example..
Any Ideas how to do this?
would appreciate quick help with this pls..
best regards
Would appreciate any urgent help here pls..
I have a 2 queries..
First query as below:
SELECT
BDVU.EQUIP_INST.DESCR, CIRC_PATH_INST.CIRC_PATH_H
FROM
BDVU.CARD_INST, BDVU.CIRC_PATH_INST, BDVU.EQUIP_INST, BDVU.EPA,
BDVU.CIRC_PATH_ELEMENT, BDVU.SITE_INST
WHERE
BDVU.EQUIP_INST.TYPE = 'IDT'
AND BDVU.EQUIP_INST.EQUIP_INST
AND BDVU.CARD_INST.CARD_INST_I
AND BDVU.CIRC_PATH_ELEMENT.POR
AND BDVU.CIRC_PATH_ELEMENT.CIR
BDVU.CIRC_PATH_INST.CIRC_P
AND BDVU.SITE_INST.SITE_INST_I
AND BDVU.CIRC_PATH_INST.CIRC_P
gives 1 row as :
DESCR CIRC_PATH_HUM_ID
IDT 103 BOWDOIN 6172273678
Second query:::
select
BDVU.SITE_INST.SITE_HUM_ID
from
BDVU.CARD_INST, BDVU.CIRC_PATH_INST, BDVU.EQUIP_INST, BDVU.EPA,
BDVU.CIRC_PATH_ELEMENT, BDVU.SITE_INST
WHERE
BDVU.EQUIP_INST.TYPE = 'POT BAY'
AND BDVU.EQUIP_INST.EQUIP_INST
AND BDVU.CARD_INST.CARD_INST_I
AND BDVU.CIRC_PATH_ELEMENT.POR
AND BDVU.CIRC_PATH_ELEMENT.CIR
BDVU.CIRC_PATH_INST.CIRC_P
AND BDVU.CIRC_PATH_INST.CIRC_P
AND BDVU.SITE_INST.SITE_INST_I
gives 1 row as below..
SITE_HUM_ID CIRC_PATH_HUM_ID
BSTNMABOHBF 6172273678
I want to union them to display result as below
SITE_HUM_ID Descr CIRC_PATH_HUM_ID
BSTNMABOHBF IDT 103 BOWDOIN 6172273678
But, please note that ...
I want to remove hard-coded CIRC_PATH_INST.CIRC_PATH_H
and want to make such that -- for each value of CIRC_PATH_INST.CIRC_PATH_H
it should execute the top query first -- and then will execute the bottom query for same
CIRC_PATH_INST.CIRC_PATH_H
Any Ideas how to do this?
would appreciate quick help with this pls..
best regards
ASKER
Sorry buddy,
I am using Oracle 8.1.7
Any help in 8.1.7 please..
Seems like I want something as like the below query -- Dont' know how to make it work though..
SELECT
BDVU.SITE_INST.SITE_HUM_ID , z, CIRC_PATH_INST.CIRC_PATH_H UM_ID
FROM
BDVU.CARD_INST, BDVU.CIRC_PATH_INST, BDVU.EQUIP_INST, BDVU.EPA,
BDVU.CIRC_PATH_ELEMENT, BDVU.SITE_INST
WHERE
BDVU.EQUIP_INST.TYPE = 'POT BAY'
AND BDVU.EQUIP_INST.EQUIP_INST _ID = BDVU.CARD_INST.EQUIP_INST_ ID
AND BDVU.CARD_INST.CARD_INST_I D = BDVU.EPA.CARD_INST_ID
AND BDVU.CIRC_PATH_ELEMENT.POR T_INST_ID = BDVU.EPA.PORT_INST_ID
AND BDVU.CIRC_PATH_ELEMENT.CIR C_PATH_INS T_ID =
BDVU.CIRC_PATH_INST.CIRC_P ATH_INST_I D
AND BDVU.SITE_INST.SITE_INST_I D = BDVU.EQUIP_INST.SITE_INST_ ID
AND BDVU.CIRC_PATH_INST.CIRC_P ATH_HUM_ID =
(
SELECT
CIRC_PATH_INST.CIRC_PATH_H UM_ID, BDVU.EQUIP_INST.DESCR z
FROM
BDVU.CARD_INST, BDVU.CIRC_PATH_INST, BDVU.EQUIP_INST, BDVU.EPA,
BDVU.CIRC_PATH_ELEMENT, BDVU.SITE_INST
WHERE
BDVU.EQUIP_INST.TYPE = 'IDT'
AND BDVU.EQUIP_INST.EQUIP_INST _ID = BDVU.CARD_INST.EQUIP_INST_ ID
AND BDVU.CARD_INST.CARD_INST_I D = BDVU.EPA.CARD_INST_ID
AND BDVU.CIRC_PATH_ELEMENT.POR T_INST_ID = BDVU.EPA.PORT_INST_ID
AND BDVU.CIRC_PATH_ELEMENT.CIR C_PATH_INS T_ID =
BDVU.CIRC_PATH_INST.CIRC_P ATH_INST_I D
AND BDVU.SITE_INST.SITE_INST_I D = BDVU.EQUIP_INST.SITE_INST_ ID
AND BDVU.CIRC_PATH_INST.CIRC_P ATH_HUM_ID = '6172273678')
I am using Oracle 8.1.7
Any help in 8.1.7 please..
Seems like I want something as like the below query -- Dont' know how to make it work though..
SELECT
BDVU.SITE_INST.SITE_HUM_ID
FROM
BDVU.CARD_INST, BDVU.CIRC_PATH_INST, BDVU.EQUIP_INST, BDVU.EPA,
BDVU.CIRC_PATH_ELEMENT, BDVU.SITE_INST
WHERE
BDVU.EQUIP_INST.TYPE = 'POT BAY'
AND BDVU.EQUIP_INST.EQUIP_INST
AND BDVU.CARD_INST.CARD_INST_I
AND BDVU.CIRC_PATH_ELEMENT.POR
AND BDVU.CIRC_PATH_ELEMENT.CIR
BDVU.CIRC_PATH_INST.CIRC_P
AND BDVU.SITE_INST.SITE_INST_I
AND BDVU.CIRC_PATH_INST.CIRC_P
(
SELECT
CIRC_PATH_INST.CIRC_PATH_H
FROM
BDVU.CARD_INST, BDVU.CIRC_PATH_INST, BDVU.EQUIP_INST, BDVU.EPA,
BDVU.CIRC_PATH_ELEMENT, BDVU.SITE_INST
WHERE
BDVU.EQUIP_INST.TYPE = 'IDT'
AND BDVU.EQUIP_INST.EQUIP_INST
AND BDVU.CARD_INST.CARD_INST_I
AND BDVU.CIRC_PATH_ELEMENT.POR
AND BDVU.CIRC_PATH_ELEMENT.CIR
BDVU.CIRC_PATH_INST.CIRC_P
AND BDVU.SITE_INST.SITE_INST_I
AND BDVU.CIRC_PATH_INST.CIRC_P
Try this:
select
y.site_hum_id
, x.descr
, x.circ_path_hum_id
FROM
( SELECT
BDVU.EQUIP_INST.DESCR, CIRC_PATH_INST.CIRC_PATH_H UM_ID
FROM
BDVU.CARD_INST, BDVU.CIRC_PATH_INST, BDVU.EQUIP_INST, BDVU.EPA,
BDVU.CIRC_PATH_ELEMENT, BDVU.SITE_INST
WHERE
BDVU.EQUIP_INST.TYPE = 'IDT'
AND BDVU.EQUIP_INST.EQUIP_INST _ID = BDVU.CARD_INST.EQUIP_INST_ ID
AND BDVU.CARD_INST.CARD_INST_I D = BDVU.EPA.CARD_INST_ID
AND BDVU.CIRC_PATH_ELEMENT.POR T_INST_ID = BDVU.EPA.PORT_INST_ID
AND BDVU.CIRC_PATH_ELEMENT.CIR C_PATH_INS T_ID =
BDVU.CIRC_PATH_INST.CIRC_P ATH_INST_I D
AND BDVU.SITE_INST.SITE_INST_I D = BDVU.EQUIP_INST.SITE_INST_ ID ) x
, ( select
BDVU.SITE_INST.SITE_HUM_ID , CIRC_PATH_INST.CIRC_PATH_H UM_ID
from
BDVU.CARD_INST, BDVU.CIRC_PATH_INST, BDVU.EQUIP_INST, BDVU.EPA,
BDVU.CIRC_PATH_ELEMENT, BDVU.SITE_INST
WHERE
BDVU.EQUIP_INST.TYPE = 'POT BAY'
AND BDVU.EQUIP_INST.EQUIP_INST _ID = BDVU.CARD_INST.EQUIP_INST_ ID
AND BDVU.CARD_INST.CARD_INST_I D = BDVU.EPA.CARD_INST_ID
AND BDVU.CIRC_PATH_ELEMENT.POR T_INST_ID = BDVU.EPA.PORT_INST_ID
AND BDVU.CIRC_PATH_ELEMENT.CIR C_PATH_INS T_ID =
BDVU.CIRC_PATH_INST.CIRC_P ATH_INST_I D
AND BDVU.SITE_INST.SITE_INST_I D = BDVU.EQUIP_INST.SITE_INST_ ID ) y
WHERE
x.circ_path_hum_id = y.circ_path_hum_id ;
Cheers
Jammalk
select
y.site_hum_id
, x.descr
, x.circ_path_hum_id
FROM
( SELECT
BDVU.EQUIP_INST.DESCR, CIRC_PATH_INST.CIRC_PATH_H
FROM
BDVU.CARD_INST, BDVU.CIRC_PATH_INST, BDVU.EQUIP_INST, BDVU.EPA,
BDVU.CIRC_PATH_ELEMENT, BDVU.SITE_INST
WHERE
BDVU.EQUIP_INST.TYPE = 'IDT'
AND BDVU.EQUIP_INST.EQUIP_INST
AND BDVU.CARD_INST.CARD_INST_I
AND BDVU.CIRC_PATH_ELEMENT.POR
AND BDVU.CIRC_PATH_ELEMENT.CIR
BDVU.CIRC_PATH_INST.CIRC_P
AND BDVU.SITE_INST.SITE_INST_I
, ( select
BDVU.SITE_INST.SITE_HUM_ID
from
BDVU.CARD_INST, BDVU.CIRC_PATH_INST, BDVU.EQUIP_INST, BDVU.EPA,
BDVU.CIRC_PATH_ELEMENT, BDVU.SITE_INST
WHERE
BDVU.EQUIP_INST.TYPE = 'POT BAY'
AND BDVU.EQUIP_INST.EQUIP_INST
AND BDVU.CARD_INST.CARD_INST_I
AND BDVU.CIRC_PATH_ELEMENT.POR
AND BDVU.CIRC_PATH_ELEMENT.CIR
BDVU.CIRC_PATH_INST.CIRC_P
AND BDVU.SITE_INST.SITE_INST_I
WHERE
x.circ_path_hum_id = y.circ_path_hum_id ;
Cheers
Jammalk
ASKER
I am trying it..
seems like it worked for 1 row (when i hard-coded circ_path_hum_id)
just want to make sure if it works for % (all data also..)
It is just taking lot of time -- since some of them are huge table..
will tell you the results in a while..
regards
seems like it worked for 1 row (when i hard-coded circ_path_hum_id)
just want to make sure if it works for % (all data also..)
It is just taking lot of time -- since some of them are huge table..
will tell you the results in a while..
regards
Just a clarification of terms, I think you don't want a union, you want a join, right? A union combines multiple rows from two queries into one result set where each query returns the same number of columns and the number of records in the result set equals the sum of the records returned by each query. A join combines columns from two (or more) different tables into the same row(s) where the number of records in the result set is the same as (or less than) the number of records in the larger table.
ASKER
Jammlk,
Your code is working.. and it works great..It is slow because of huge DB..
But is does work great..
But I actually prepared 2 views for each of two selects, and then ran my select as
select distinct
SITE_HUM_ID, DESCR
FROM TEMP_IDT,
TEMP_POTBAY
WHERE
TEMP_IDT.CIRC_PATH_HUM_ID = TEMP_POTBAY.CIRC_PATH_HUM_ ID
TEMP_IDT is a view from top select
TEMP_POTDAY is a view for bottom select..
I have another urgent Q, if you can help pls.. and I will close this Q..
With the above data, I get some 400 rows right ?(from views)
I want to run following roughly following update --
update equip_attr_settings
set attr_value=<site_hum_id> -- i get from above select
where
and c.attr_name= 'DOWNSTREAM COLO'
and c.EQUIP_INST_ID =d.EQUIP_INST_ID
and d.DESCR=<desc> -- i got from above select
In this,
equip_attr_settings c, EQUIP_INST d
Any ideas how to accomplish this please..
I appreciate your help..
Regards
Your code is working.. and it works great..It is slow because of huge DB..
But is does work great..
But I actually prepared 2 views for each of two selects, and then ran my select as
select distinct
SITE_HUM_ID, DESCR
FROM TEMP_IDT,
TEMP_POTBAY
WHERE
TEMP_IDT.CIRC_PATH_HUM_ID = TEMP_POTBAY.CIRC_PATH_HUM_
TEMP_IDT is a view from top select
TEMP_POTDAY is a view for bottom select..
I have another urgent Q, if you can help pls.. and I will close this Q..
With the above data, I get some 400 rows right ?(from views)
I want to run following roughly following update --
update equip_attr_settings
set attr_value=<site_hum_id> -- i get from above select
where
and c.attr_name= 'DOWNSTREAM COLO'
and c.EQUIP_INST_ID =d.EQUIP_INST_ID
and d.DESCR=<desc> -- i got from above select
In this,
equip_attr_settings c, EQUIP_INST d
Any ideas how to accomplish this please..
I appreciate your help..
Regards
Try this:
This is the simple way just use your twos SQL as a on-line view and then join them.
select b.SITE_HUM_ID,a.Desc,a.CIR
from
(
SELECT
BDVU.EQUIP_INST.DESCR, CIRC_PATH_INST.CIRC_PATH_H
FROM
BDVU.CARD_INST, BDVU.CIRC_PATH_INST, BDVU.EQUIP_INST, BDVU.EPA,
BDVU.CIRC_PATH_ELEMENT, BDVU.SITE_INST
WHERE
BDVU.EQUIP_INST.TYPE = 'IDT'
AND BDVU.EQUIP_INST.EQUIP_INST
AND BDVU.CARD_INST.CARD_INST_I
AND BDVU.CIRC_PATH_ELEMENT.POR
AND BDVU.CIRC_PATH_ELEMENT.CIR
BDVU.CIRC_PATH_INST.CIRC_P
AND BDVU.SITE_INST.SITE_INST_I
-- AND BDVU.CIRC_PATH_INST.CIRC_P
) a,
(
select
BDVU.SITE_INST.SITE_HUM_ID
from
BDVU.CARD_INST, BDVU.CIRC_PATH_INST, BDVU.EQUIP_INST, BDVU.EPA,
BDVU.CIRC_PATH_ELEMENT, BDVU.SITE_INST
WHERE
BDVU.EQUIP_INST.TYPE = 'POT BAY'
AND BDVU.EQUIP_INST.EQUIP_INST
AND BDVU.CARD_INST.CARD_INST_I
AND BDVU.CIRC_PATH_ELEMENT.POR
AND BDVU.CIRC_PATH_ELEMENT.CIR
BDVU.CIRC_PATH_INST.CIRC_P
-- AND BDVU.CIRC_PATH_INST.CIRC_P
AND BDVU.SITE_INST.SITE_INST_I
where a.CIRC_PATH_HUM_ID = b.CIRC_PATH_HUM_ID
ASKER
Danielzt,
Jammlk has already given the same solution .. I appreciate your help with this anyway..
Can you or Jammlk or anybody can help me with my other question please ..
How to update based on this select.. please read my second question just before Danielzt's comment..
I would really appreciate your help with this last Question .... please...
regards
Jammlk has already given the same solution .. I appreciate your help with this anyway..
Can you or Jammlk or anybody can help me with my other question please ..
How to update based on this select.. please read my second question just before Danielzt's comment..
I would really appreciate your help with this last Question .... please...
regards
Hmm.. Question is not clear..!
R u trying to update a new table here called EQUIP_ATTR_SETTINGS ?
Can u paste the column structure of this table here ?
Also, let me know if u r trying to update any other tables..? Coz.. in the where clause I see "equip_attr_settings c, EQUIP_INST d" tables being used.
Jammalk
R u trying to update a new table here called EQUIP_ATTR_SETTINGS ?
Can u paste the column structure of this table here ?
Also, let me know if u r trying to update any other tables..? Coz.. in the where clause I see "equip_attr_settings c, EQUIP_INST d" tables being used.
Jammalk
ASKER
Jammlk,
Thanks for response.. Sorry for not explaining it clearly..
okay..
there are 2 views --
TEMP_IDT and TEMP_POTBAY (from the selects you helped me with already)..
TEMP_IDT with following columns
DESCR
CIRC_PATH_HUM_ID
TEMP_POTBAY with following columns
SITE_HUM_ID
CIRC_PATH_HUM_ID
Lets assume, I create a table as below:
CREATE TABLE TEMP_IDT_POTBAY_MAPPING AS
( select distinct SITE_HUM_ID, DESCR FROM TEMP_IDT, TEMP_POTBAY WHERE TEMP_IDT.CIRC_PATH_HUM_ID = TEMP_POTBAY.CIRC_PATH_HUM_ ID)
So now
TEMP_IDT_POTBAY_MAPPING has 2 columns --
SITE_HUM_ID AND DESCR (Mapping)
I want to write an update as below:
update EQUIP_ATTR_SETTINGS
set EQUIP_ATTR_SETTINGS.ATTR_V ALUE = <SITE_HUM_ID> -- from above mapping table
WHERE
EQUIP_ATTR_SETTINGS.EQUIP_ INST_ID=
(select EQUIP_ATTR_SETTINGS.EQUIP_ INST_ID
from EQUIP_ATTR_SETTINGS, EQUIP_INST, VAL_ATTR_NAME
where VAL_ATTR_NAME.ATTR_NAME='D OWNSTREAM COLO'
and EQUIP_ATTR_SETTINGS.EQUIP_ INST_ID=EQ UIP_INST.E QUIP_INST_ ID
and EQUIP_INST.DESCR= <DESCR> -- from above mapping table
and VAL_ATTR_NAME.VAL_ATTR_INS T_ID = EQUIP_ATTR_SETTINGS.VAL_AT TR_INST_ID
)
Got it?
Let me know if it still not clear..
Regards
Thanks for response.. Sorry for not explaining it clearly..
okay..
there are 2 views --
TEMP_IDT and TEMP_POTBAY (from the selects you helped me with already)..
TEMP_IDT with following columns
DESCR
CIRC_PATH_HUM_ID
TEMP_POTBAY with following columns
SITE_HUM_ID
CIRC_PATH_HUM_ID
Lets assume, I create a table as below:
CREATE TABLE TEMP_IDT_POTBAY_MAPPING AS
( select distinct SITE_HUM_ID, DESCR FROM TEMP_IDT, TEMP_POTBAY WHERE TEMP_IDT.CIRC_PATH_HUM_ID = TEMP_POTBAY.CIRC_PATH_HUM_
So now
TEMP_IDT_POTBAY_MAPPING has 2 columns --
SITE_HUM_ID AND DESCR (Mapping)
I want to write an update as below:
update EQUIP_ATTR_SETTINGS
set EQUIP_ATTR_SETTINGS.ATTR_V
WHERE
EQUIP_ATTR_SETTINGS.EQUIP_
(select EQUIP_ATTR_SETTINGS.EQUIP_
from EQUIP_ATTR_SETTINGS, EQUIP_INST, VAL_ATTR_NAME
where VAL_ATTR_NAME.ATTR_NAME='D
and EQUIP_ATTR_SETTINGS.EQUIP_
and EQUIP_INST.DESCR= <DESCR> -- from above mapping table
and VAL_ATTR_NAME.VAL_ATTR_INS
)
Got it?
Let me know if it still not clear..
Regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SELECT
x.SITE_HUM_ID
, x.descr
, x.CIRC_PATH_HUM_ID
FROM
( WITH a AS (
SELECT
BDVU.EQUIP_INST.DESCR, CIRC_PATH_INST.CIRC_PATH_H
FROM
BDVU.CARD_INST, BDVU.CIRC_PATH_INST, BDVU.EQUIP_INST, BDVU.EPA,
BDVU.CIRC_PATH_ELEMENT, BDVU.SITE_INST
WHERE
BDVU.EQUIP_INST.TYPE = 'IDT'
AND BDVU.EQUIP_INST.EQUIP_INST
AND BDVU.CARD_INST.CARD_INST_I
AND BDVU.CIRC_PATH_ELEMENT.POR
AND BDVU.CIRC_PATH_ELEMENT.CIR
BDVU.CIRC_PATH_INST.CIRC_P
AND BDVU.SITE_INST.SITE_INST_I
-- AND BDVU.CIRC_PATH_INST.CIRC_P
)
select
BDVU.SITE_INST.SITE_HUM_ID
from
BDVU.CARD_INST, BDVU.CIRC_PATH_INST, BDVU.EQUIP_INST, BDVU.EPA,
BDVU.CIRC_PATH_ELEMENT, BDVU.SITE_INST, a
WHERE
BDVU.EQUIP_INST.TYPE = 'POT BAY'
AND BDVU.EQUIP_INST.EQUIP_INST
AND BDVU.CARD_INST.CARD_INST_I
AND BDVU.CIRC_PATH_ELEMENT.POR
AND BDVU.CIRC_PATH_ELEMENT.CIR
BDVU.CIRC_PATH_INST.CIRC_P
-- AND BDVU.CIRC_PATH_INST.CIRC_P
AND BDVU.SITE_INST.SITE_INST_I
AND a.circ_path_hum_id = CIRC_PATH_INST.CIRC_PATH_H
To make it easier to understand, lets call the first query q1 and second query q2 (with out BDVU.CIRC_PATH_INST.CIRC_P
Then, the query I gave u looks as follows:
select
x.SITE_HUM_ID
, x.descr
, x.CIRC_PATH_HUM_ID
from
( WITH a AS (q1) q2 ) x.
Let me know if this works for ya.
Cheers
Jammalk