我试图在我的数据库上创建一个新视图,但出于某种原因,每次我尝试这样做时,视图本身都不会返回任何数据并使我失去与服务器的连接。 有趣的是,如果我直接在服务器上运行我的整个查询而没有查看它会返回所有行而没有问题。
以下是我使用的查询:
SELECT C.*,
(CASE
WHEN C.TEC = 'Ind'
THEN (select distinct I."FINAL" from IND I WHERE I.GUIDE = C.GUIDE AND ROWNUM = 1)
ELSE (select distinct Z."FINAL" from NEST Z WHERE Z.TYPE = C.TYPE AND ROWNUM = 1)
END) FINAL_POINT,
(CASE
WHEN C.TEC = 'Ind'
THEN (select count(distinct I."FINAL") from IND I WHERE I.GUIDE = C.GUIDE)
ELSE (select count(distinct Z."FINAL") from NEST Z WHERE Z.TYPE = C.TYPE)
END) COUNT_FINAL_POINT
FROM
(SELECT A.*,(select TYPE from AUX B where A.REF = B.REF AND A.TEC != 'Ind') TYPE
FROM NCL A) C
知道这里发生了什么吗?