I recently had to move my database from SQL Studio over to Oracle and I am learning about all the different syntaxes that must be used.
Anyways, I have run into a problem today where a query I am trying to execute runs forever (> 15 min) and never seems to finish.
As you can see I use the With statement to create 2 temp. tables from which I run my query. If I query either of these tables individually, I get results in < 2 seconds. As soon as I add the other table in the From statement it doesn't seem to do anything.
This query works fine:
With Laser as
(
SELECT Data.Serial_Number, Equipment.Equipment_Desc, Data.SCAN_TIME,
ROW_NUMBER() OVER (PARTITION BY Data.Serial_Number, Equipment.Equipment_SN
ORDER BY Equipment.Equipment_SN) AS RN
FROM Data, Equipment
where Data.Equipment_Station = Equipment.Equipment_SN and Equipment.Equipment_Desc like '%laser Etch%'
)
,AssyQC AS
(
SELECT Data.Serial_Number, Equipment.Equipment_Desc,Data.SCAN_TIME,
ROW_NUMBER() OVER (PARTITION BY Data.Serial_Number, Equipment.Equipment_SN
ORDER BY Equipment.Equipment_SN) AS RN
FROM Data, Equipment
where Data.Equipment_Station = Equipment.Equipment_SN and Equipment.Equipment_Desc like '%QSMC SI%'
)
select to_char(Laser.SCAN_TIME, 'mm') as "Laser Month", to_char(Laser.SCAN_TIME, 'dd') as "Laser Day"
from Laser
;
Now, if I add the other table to the From statement, even though I don't use it anywhere else (select, where, etc.) the query doesn't do anything. It runs and runs and runs...
With Laser as
(
SELECT Data.Serial_Number, Equipment.Equipment_Desc, Data.SCAN_TIME,
ROW_NUMBER() OVER (PARTITION BY Data.Serial_Number, Equipment.Equipment_SN
ORDER BY Equipment.Equipment_SN) AS RN
FROM Data, Equipment
where Data.Equipment_Station = Equipment.Equipment_SN and Equipment.Equipment_Desc like '%laser Etch%'
)
,AssyQC AS
(
SELECT Data.Serial_Number, Equipment.Equipment_Desc,Data.SCAN_TIME,
ROW_NUMBER() OVER (PARTITION BY Data.Serial_Number, Equipment.Equipment_SN
ORDER BY Equipment.Equipment_SN) AS RN
FROM Data, Equipment
where Data.Equipment_Station = Equipment.Equipment_SN and Equipment.Equipment_Desc like '%QSMC SI%'
)
select to_char(Laser.SCAN_TIME, 'mm') as "Laser Month", to_char(Laser.SCAN_TIME, 'dd') as "Laser Day"
from Laser, AssyQC
;
This query worked fine in SQL Studio.
Any ideas??