Crystal Reports中的“多部分标识符无法绑定”与SQL表达式/子查询
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Crystal Reports中的“多部分标识符无法绑定”与SQL表达式/子查询相关的知识,希望对你有一定的参考价值。
我正在使用Crystal Reports,它使您能够创建称为SQL表达式的东西。它们基本上是子查询,但是有限,因此每个SQL表达式只能返回一个标量值。有关更多信息,请访问:http://www.cogniza.com/wordpress/2005/11/07/crystal-reports-using-sql-expression-fields/
引用文章非常具体地说:
If you are using a SQL Expression as a subquery and wish to link it to the
detail row of your main report, do not include the table you wish to link to
in the FROM clause of the subquery. For example:
(
SELECT MAX("FLOWSHEET"."VALUE")
FROM FLOWSHEET
WHERE "FLOWSHEET"."ID" in ('11')
AND "FLOWSHEET"."IP_ID" = "HOSPITAL_VISIT"."IP_ID"
)
The above query links to the HOSPITAL_VISIT table in the main report by
linking to the IP_ID field. To accomplish this, HOSPITAL_VISIT is omitted
from the FROM clause in the query.
我的报告中有一个主查询说:
SELECT
HIFIS_HousePlacements.MovedInDate,
vw_ClientBasics.LastName,
vw_ClientBasics.FirstName,
HIFIS_Clients_HousePlacements.ClientID
FROM
HIFIS_Clients_HousePlacements
INNER JOIN HIFIS_HousePlacements ON HIFIS_Clients_HousePlacements.HousePlacementID=HIFIS_HousePlacements.HousePlacementID
INNER JOIN vw_ClientBasics ON HIFIS_Clients_HousePlacements.ClientID=vw_ClientBasics.ClientID
现在我想添加一个SQL表达式
(
SELECT TOP 1 AssessmentAcuityType
FROM vw_IntakeAssessmentAcuityScores
WHERE vw_IntakeAssessmentAcuityScores.ClientID=HIFIS_Clients_HousePlacements.ClientID
AND vw_IntakeAssessmentAcuityScores.AssessmentTool = 'SPDAT'
AND vw_IntakeAssessmentAcuityScores.AssessmentToolType NOT LIKE '%VI%'
AND vw_IntakeAssessmentAcuityScores.IntakeDate BETWEEN DATEADD(month,-6,HIFIS_HousePlacements.MovedInDate) AND HIFIS_HousePlacements.MovedInDate
ORDER BY IntakeID DESC
)
当我这样做时,我得到错误The multi-part identifier HIFIS_HousePlacements.MovedInDate cannot be bound
因此,虽然我知道我没有在子查询中定义HIFIS_HousePlacements,但SQL表达式字段的规则表明我不应该这样做。有谁能帮我理解如何解决这个错误?
答案
我已经解决了部分问题。
部分问题依赖于等式边的顺序。
所以我确定这会导致错误:
(
SELECT TOP 1 AssessmentAcuityType
FROM vw_IntakeAssessmentAcuityScores
WHERE vw_IntakeAssessmentAcuityScores.ClientID=HIFIS_Clients_HousePlacements.ClientID
)
而事实并非如此
(
SELECT TOP 1 AssessmentAcuityType
FROM vw_IntakeAssessmentAcuityScores
WHERE HIFIS_Clients_HousePlacements.ClientID=vw_IntakeAssessmentAcuityScores.ClientID
)
以上是关于Crystal Reports中的“多部分标识符无法绑定”与SQL表达式/子查询的主要内容,如果未能解决你的问题,请参考以下文章
使用 RESTful Web 服务的结果作为 Crystal Reports 中的数据
如何在Crystal Reports中的StringVar中插入换行符
Crystal Reports中的“多部分标识符无法绑定”与SQL表达式/子查询