我们有一个非常简单的Crystal Report,只是从我们的Viewpoint数据库中提取有关作业的信息。唯一的参数是公司,部门和状态,每个参数的默认值都不会更改。
运行报表时,应使用已输入的新作业,新金额等进行更新。相反,所有数据保持不变,并且自上次运行报表后输入的作业不会显示
这是我们的代码:
SELECT
"JCJMPM"."Job",
"JCJMPM"."Description",
"JCCM"."ContractAmt",
"JCCM"."JCCo",
"JCCM"."Department",
"JCCM"."ContractStatus",
"JCMP"."Name",
"ARCM"."Name"
FROM
(("Viewpoint"."dbo"."JCJMPM" "JCJMPM" LEFT OUTER JOIN "Viewpoint"."dbo"."JCCM" "JCCM" ON ("JCJMPM"."JCCo"="JCCM"."JCCo") AND ("JCJMPM"."Contract"="JCCM"."Contract"))
LEFT OUTER JOIN "Viewpoint"."dbo"."JCMP" "JCMP" ON ("JCJMPM"."JCCo"="JCMP"."JCCo") AND ("JCJMPM"."ProjectMgr"="JCMP"."ProjectMgr"))
LEFT OUTER JOIN "Viewpoint"."dbo"."ARCM" "ARCM" ON ("JCCM"."CustGroup"="ARCM"."CustGroup") AND ("JCCM"."Customer"="ARCM"."Customer")
WHERE
"JCCM"."JCCo"=1
AND "JCCM"."Department"='50'
AND "JCCM"."ContractStatus"=1
ORDER BY
"JCCM"."JCCo",
"JCCM"."Department",
"JCCM"."ContractStatus"
答案 0 :(得分:2)
你有一个左连接:LEFT OUTER JOIN" Viewpoint"。" dbo"。" JCCM" " JCCM"
和Where子句:WHERE
" JCCM"" JCCo" = 1
和" JCCM"。"部门" =' 50'
AND" JCCM"。" ContractStatus" = 1
where子句将终止左连接并将其转换为内连接,将SQL更改为此连接并再试一次:
SELECT
"JCJMPM"."Job",
"JCJMPM"."Description",
"JCCM"."ContractAmt",
"JCCM"."JCCo",
"JCCM"."Department",
"JCCM"."ContractStatus",
"JCMP"."Name",
"ARCM"."Name"
FROM
(("Viewpoint"."dbo"."JCJMPM" "JCJMPM"
LEFT OUTER JOIN "Viewpoint"."dbo"."JCCM" "JCCM" ON ("JCJMPM"."JCCo"="JCCM"."JCCo") AND ("JCJMPM"."Contract"="JCCM"."Contract")
AND "JCCM"."JCCo"=1
AND "JCCM"."Department"='50'
AND "JCCM"."ContractStatus"=1
)
LEFT OUTER JOIN "Viewpoint"."dbo"."JCMP" "JCMP" ON ("JCJMPM"."JCCo"="JCMP"."JCCo") AND ("JCJMPM"."ProjectMgr"="JCMP"."ProjectMgr"))
LEFT OUTER JOIN "Viewpoint"."dbo"."ARCM" "ARCM" ON ("JCCM"."CustGroup"="ARCM"."CustGroup") AND ("JCCM"."Customer"="ARCM"."Customer")
ORDER BY
"JCCM"."JCCo",
"JCCM"."Department",
"JCCM"."ContractStatus"