所以我对这个程序很陌生,无法弄清楚为什么我会收到这个错误。 这是qry。
SELECT policy_no,
phase_code,
sub_phase_code,
Duplicate_Indicator = CASE
WHEN Sum(1) <> 1 THEN 'DUPLICATE'
ELSE 'NOT DUPLICATE'
END
FROM qrypolicylistfornydefpremasset_re
RIGHT JOIN (SELECT TOP 100 PERCENT tblinsurance.policy_no,
tblinsurance.phase_code,
tblinsurance.sub_phase_code,
tblinsurance.prodtype,
tblinsurance.paid_to_date,
tblinsurance.val_date,
tblinsurance.issue_date,
tblinsurance.schednp,
Sum(tblinsurance.gross_annlzd_prem) AS
SumOfGROSS_ANNLZD_PREM,
Sum(tblinsurance.statnetpremium) AS
SumOfStatNetPremium,
Sum(tblinsurance.netdefpremium) AS
SumOfNetDefPremium,
Sum(tblinsurance.netdefextra) AS
SumOfNetDefExtra,
Sum(tblinsurance.netdefpremiumadj) AS
SumOfNetDefPremiumAdj,
Sum(tblinsurance.netdefextraadj) AS
SumOfNetDefExtraAdj,
NetvsGrossInd = CASE
WHEN
[netdefpremium] = [netdefpremiumadj]
THEN
'Net'
ELSE 'Gross'
END,
Sum(tblinsurance.amount_inforce) AS
SumOfAMOUNT_INFORCE,
Sum(tblinsurance.pua_face) AS
SumOfPUA_FACE,
Sum(tblinsurance.oyt_face) AS
SumOfOYT_FACE
FROM tblinsurance
WHERE ( ( ( tblinsurance.company_code ) = 'NL' )
AND ( ( tblinsurance.term_reason ) = 'A' )
AND ( ( tblinsurance. issue_date ) <= [val_date] ) )
GROUP BY tblinsurance.policy_no,
tblinsurance.phase_code,
tblinsurance.sub_phase_code,
tblinsurance.prodtype,
tblinsurance.paid_to_date,
tblinsurance.val_date,
tblinsurance.issue_date,
tblinsurance.schednp,
CASE
WHEN [netdefpremium] = [netdefpremiumadj] THEN
'Net'
ELSE 'Gross'
END
HAVING (( ( Sum(tblinsurance.netdefpremium) ) <> 0 )))Work
ON policy_no = qrypolicylistfornydefpremasset_re.policy_no
AND phase_code = qrypolicylistfornydefpremasset_re.phase_code
AND sub_phase_code =
qrypolicylistfornydefpremasset_re.sub_phase_code
GROUP BY policy_no,
phase_code,
sub_phase_code
我得到的模糊列名在Fields POLICY_NO,PHASE_CODE,SUB_PHASE_CODE上,但只在末尾的On和GROUP by以及开头的SELECT中。
答案 0 :(得分:4)
嗯,你们两个都有这些领域
qryPolicyListforNYDefPRemAsset_Re
并在您的子查询中Work
所以在前面加上正确的表格(或者更好,使用别名)。
我在Work
和SELECT
以及GROUP BY
中以JOIN
为前缀我可能错误SELECT
和GROUP BY
(也许您需要{ {1}},q
的别名:我喜欢Sql,你的查询对我来说太模糊了;)
qryPolicyListforNYDefPRemAsset_Re