是否可以将命令的结果用于 Crystal Reports 中的另一个命令?
例如,我有一个命令
SELECT foo FROM bar WHERE foo2 IN (list)
另存为 command_1
现在我想要
SELECT xfoo FROM xbar WHERE xfoo2 IN (command_1.foo)
在一个简单的情况下,我意识到我可以将它们结合起来
SELECT xfoo FROM xbar WHERE xfoo2 IN (SELECT foo FROM bar WHERE foo2 IN (list))
但在我的现实世界中,由于嵌套 SELECT 太多而给我带来了错误。
如果有人想给出一个具体的而不是一般的答案,我的现实世界的例子:
现有命令另存为pnr
:
SELECT DISTINCT rem.pop_pid
FROM a_remiss rem
INNER JOIN a_bestall best ON rem.arem_id = best.arem_id
JOIN a_prov prov ON best.apro_id = prov.apro_id
WHERE prov.pro_provdat >= {ts '2006-01-01 00:00:00'}
AND prov.pro_provdat <= {ts '2011-12-31 23:59:59'}
AND best.ana_analyskod IN ('PKREAT', 'PKREA', 'PKREAN')
AND (
rem.pop_pid LIKE '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] 1[89]'
OR rem.pop_pid LIKE '[01][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] 20'
)
想要额外的新命令:
SELECT arem_id, apro_id, ana_analyskod
FROM a_bestall
WHERE ana_analyskod IN('ABSBIK', 'BCRPS')
AND arem_id IN (
SELECT arem_id
FROM a_remiss
WHERE rem_ank_dttm >= {ts '2006-01-01 00:00:00'}
AND rem_ank_dttm <= {ts '2012-01-31 23:59:59'}
AND pop_pid IN pnr.pop_pid
)
编辑:修复了现在使嵌套 SELECT 工作的代码错误,但能够嵌套命令仍然很好。