在我的查询设计器中,我尝试使用以下查询:
SELECT Site, LegalConfigNumber, COUNT(*) AS Total
FROM EPSInfoLive
iif(@LegalConfigNum = 0,
WHERE (InputDate >= @rundate) AND (InputDate <= DATEADD(day, 1, @rundate)),
WHERE (InputDate >= @rundate) AND (InputDate <= DATEADD(day, 1, @rundate)) AND LegalConfigNumber = @LegalConfigNum)
GROUP BY LegalConfigNumber, Site
ORDER BY Site, LegalConfigNumber
当我尝试测试它时,我收到有关@LegalConfigNum语法错误的消息。 我似乎无法找到它的位置。
答案 0 :(得分:2)
SSRS查询需要用SQL编写。您正在使用'@iif'混合使用SQL和Visual Basic。 SQL支持CASE语句而不是IIF。但是你不需要这个就是你所展示的。以下陈述应在逻辑上等同:
SELECT
Site,
LegalConfigNumber,
COUNT(*) AS Total
FROM
EPSInfoLive
WHERE
(InputDate >= @rundate) AND (InputDate <= DATEADD(day, 1, @rundate))
AND (LegalConfigNumber = @LegalConfigNum OR @LegalConfigNum = 0)
GROUP BY LegalConfigNumber, Site
ORDER BY Site, LegalConfigNumber