我需要显示一个表格,其中coloumns为TEST_NAME,TEST_PRODUCT,status1,status2。这里status1应该是外部查询中选择的test_name的状态。 状态2也是在外部查询中但在不同环境中选择的相同测试的状态。我的查询存在以下问题。
select TEST_NAME, TEST_PRODUCT,
(
SELECT DR_STATUS FROM PRCQA.PRCBUILD_DR_DAILYRUN@FARMJANGO DAILYRUN,PRCQA.PRCBUILD_DR_TEST@FARMJANGO TEST,PRCQA.PRCBUILD_DR_ENV@FARMJANGO ENV WHERE
DAILYRUN.TEST_ID=TEST.ID AND
TEST.TEST_PRODUCT IN ('Product Model', 'Product and Catalog Management','Product Hub', 'Product Hub Portal')
AND ENV.ENV_NAME LIKE :P2_ENV1 AND DAILYRUN.DR_DATE = to_char (to_date(:P2_DATE1,'DD-Mon-YYYY'), 'DD-MM-YYYY')
) as status1,
(
SELECT DR_STATUS FROM PRCQA.PRCBUILD_DR_DAILYRUN@FARMJANGO DAILYRUN,PRCQA.PRCBUILD_DR_TEST@FARMJANGO TEST,PRCQA.PRCBUILD_DR_ENV@FARMJANGO ENV WHERE
DAILYRUN.TEST_ID=TEST.ID AND
TEST.TEST_PRODUCT IN ('Product Model', 'Product and Catalog Management','Product Hub', 'Product Hub Portal')
AND ENV.ENV_NAME LIKE :P2_ENV2 AND DAILYRUN.DR_DATE = to_char (to_date(:P2_DATE2,'DD-Mon-YYYY'), 'DD-MM-YYYY')
) as status2
from PRCQA.PRCBUILD_DR_DAILYRUN@FARMJANGO DAILYRUN, PRCQA.PRCBUILD_DR_TEST@FARMJANGO TESTOUT
where DAILYRUN.TEST_ID=TESTOUT.ID AND TESTOUT.TEST_PRODUCT IN ('Product Model', 'Product and Catalog Management','Product Hub', 'Product Hub Portal')
答案 0 :(得分:0)
希望这会对你有所帮助
SELECT TEST_NAME
,TEST_PRODUCT
,(
SELECT TOP (1) DR_STATUS
FROM PRCQA.PRCBUILD_DR_DAILYRUN@FARMJANGO DAILYRUN
,PRCQA.PRCBUILD_DR_TEST@FARMJANGO TEST
,PRCQA.PRCBUILD_DR_ENV@FARMJANGO ENV
WHERE DAILYRUN.TEST_ID = TEST.ID
AND TEST.TEST_PRODUCT IN (
'Product Model'
,'Product and Catalog Management'
,'Product Hub'
,'Product Hub Portal'
)
AND ENV.ENV_NAME LIKE :P2_ENV1
AND DAILYRUN.DR_DATE = to_char(to_date(:P2_DATE1, 'DD-Mon-YYYY'), 'DD-MM-YYYY')
) AS status1
,(
SELECT TOP (1) DR_STATUS
FROM PRCQA.PRCBUILD_DR_DAILYRUN@FARMJANGO DAILYRUN
,PRCQA.PRCBUILD_DR_TEST@FARMJANGO TEST
,PRCQA.PRCBUILD_DR_ENV@FARMJANGO ENV
WHERE DAILYRUN.TEST_ID = TEST.ID
AND TEST.TEST_PRODUCT IN (
'Product Model'
,'Product and Catalog Management'
,'Product Hub'
,'Product Hub Portal'
)
AND ENV.ENV_NAME LIKE :P2_ENV2
AND DAILYRUN.DR_DATE = to_char(to_date(:P2_DATE2, 'DD-Mon-YYYY'), 'DD-MM-YYYY')
) AS status2
FROM PRCQA.PRCBUILD_DR_DAILYRUN@FARMJANGO DAILYRUN
,PRCQA.PRCBUILD_DR_TEST@FARMJANGO TESTOUT
WHERE DAILYRUN.TEST_ID = TESTOUT.ID
AND TESTOUT.TEST_PRODUCT IN (
'Product Model'
,'Product and Catalog Management'
,'Product Hub'
,'Product Hub Portal'
)