我有一个问题输出我的查询作为一个表从我的下一个查询中选择值,请建议您的观点。
我使用的数据库表示例:
第一次查询:
WITH TABLE1
AS (SELECT COT.DESCRIPTION
FROM CONFIGURABLEOBJECTTYPE COT
WHERE COT.CONFIGURABLEOBJECTTYPEID IN (SELECT CIO.DAMAGEDCOTEMPLATE
FROM CLAIMINSURANCEOBJECT CIO
INNER JOIN CLAIMRISKUNIT CRU ON CRU.CLAIMRISKUNITID = CIO.CLAIMRISKUNITID
INNER JOIN CLAIM CL ON CL.CLAIMID = CRU.CLAIMID
INNER JOIN AGREGATEDPOLICY APO ON CL.POLICYID = APO.AGREGATEDPOLICYID))
输出:
RecSuiVidaCol,
RecSuiSegMigranteVida,
RecEnfSegMigranteVida,
RecAccPasajeroSeguro,
RecAgrSaldosDeudores,
RecEnfPasajeroSeguro,
RecAccSegMigranteVida,
RecAccVidaCol,
(以上所有都是DB Tables)
现在我的第二个查询:
SELECT * FROM TABLE1 WHERE PK IN (SELECT CIO.DAMAGEDCOID
FROM CLAIMINSURANCEOBJECT CIO
INNER JOIN CLAIMRISKUNIT CRU ON CRU.CLAIMRISKUNITID = CIO.CLAIMRISKUNITID
INNER JOIN CLAIM CL ON CL.CLAIMID = CRU.CLAIMID
INNER JOIN AGREGATEDPOLICY APO ON CL.POLICYID = APO.AGREGATEDPOLICYID);
此处未识别字段PK。 我想根据条件
将所有字段作为表的输出答案 0 :(得分:0)
CTE(with
条款),也许?
WITH XYZ
AS (
SELECT 'Ayub' as Name
FROM Dual
)
SELECT *
FROM XYZ;
答案 1 :(得分:0)
以下是针对SQL * Plus的。它可以在SQL Developer中工作,因为它可以很好地模拟SQL * Plus:
SQL> column testname new_value testname
SQL> select 'user_sequences' as testname from dual;
old 1: select count(*) from &testname
new 1: select count(*) from user_sequences
TESTNAME
--------------
user_sequences
1 row selected.
SQL> select count(*) from &testname;
COUNT(*)
----------
4
1 row selected.
SQL> define testname
DEFINE TESTNAME = "user_sequences" (CHAR)
注意:
显示old
和new
值,因为我set verify on
。
new_value
选项是column
command。