在Web报表编写器中查询抛出错误

时间:2014-09-19 15:42:33

标签: tsql

我创建了一个用于报表的查询/视图。当我在SMS和SSRS中运行它运行正常。但是当我将视图连接到生成报告的工具时,它会抛出以下错误。 ' .8'附近的语法不正确。当我联系该产品的支持时,他们说这与我们如何计算8thgradyear有关。我在下面放了代码。任何建议。

SELECT        
dbo.studemo.suniq, 
dbo.studemo.ident, 
dbo.studemo.lastname,
dbo.studemo.firstname,
dbo.studemo.emailaddr AS stuemail, 
dbo.studemo.birthdate, 
dbo.track.schoolc, 
dbo.school.schname, 
dbo.stustat.graden,
dbo.stustat.edate, 
dbo.zstustat.descript AS status, 
RTRIM(dbo.facdemo.lastname) + '  ' + dbo.facdemo.firstname AS advisor, 
dbo.track.schyear,
SUM(8) - dbo.stustat.graden + dbo.track.schyear AS [8thgradyear],
sf.Email, LOWER(sf.Username) AS [user],
LOWER(RIGHT(SUM(8) - dbo.stustat.graden + dbo.track.schyear, 2) + LEFT(dbo.studemo.firstname, 1) + REPLACE(REPLACE(REPLACE(dbo.studemo.lastname, '-', ''), ' ', ''), '''', '') + RIGHT(dbo.studemo.ident, 3)) AS newuser, 
CONVERT(varchar(8), dbo.studemo.birthdate,1) AS password, 
'STUDENTS' + '/' + (CASE WHEN track.schoolc IN ('19', '43', '17', '23') THEN 'Middle' ELSE 'Elementary' END) + '/' + dbo.school.schname AS neworg, 
                         sf.OU, sf.LastLoginTime
FROM            dbo.studemo INNER JOIN
                         dbo.stustat ON dbo.studemo.suniq = dbo.stustat.suniq INNER JOIN
                         dbo.track ON dbo.stustat.trkuniq = dbo.track.trkuniq INNER JOIN
                         dbo.zstustat ON dbo.stustat.stustatc = dbo.zstustat.stustatc INNER JOIN
                         dbo.facdemo ON dbo.stustat.funiq = dbo.facdemo.funiq LEFT OUTER JOIN
                         dbo.vw_google_OU AS sf ON sf.Firstname = dbo.studemo.firstname AND sf.Lastname = dbo.studemo.lastname INNER JOIN
                         dbo.school ON dbo.school.schoolc = dbo.track.schoolc
WHERE        (dbo.stustat.stustatc IN
                             (SELECT        stustatc
                               FROM            dbo.zstustat AS zstustat_1
                               WHERE        (snstatus IN ('A', 'M', 'P')))) AND (dbo.stustat.xdate IS NULL OR
                         dbo.stustat.xdate < dbo.stustat.edate) AND (dbo.track.schoolc NOT IN ('P34', 'P24', '802', '801'))
GROUP BY dbo.studemo.suniq, dbo.studemo.ident, dbo.studemo.lastname, dbo.studemo.firstname, dbo.studemo.birthdate, RIGHT(dbo.studemo.ident, 3), dbo.track.schoolc, 
                         dbo.stustat.graden, dbo.zstustat.descript, RTRIM(dbo.facdemo.lastname) + '  ' + dbo.facdemo.firstname, dbo.stustat.edate, dbo.studemo.gradyear, dbo.track.schyear, 
                         sf.Email, CONVERT(varchar(8), dbo.studemo.birthdate, 1), sf.Username, dbo.school.schname, sf.OU, dbo.studemo.emailaddr, sf.LastLoginTime

1 个答案:

答案 0 :(得分:0)

SUM函数是在SQL Server 2008中引入的,您的工具必​​须使用旧版本的SQL Server。