Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'as'.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-09-03 : 09:10:48
Paul writes "We are using Nt4.0 and SQL Server 7.0

SELECT COUNT(t_PART.FSC) AS 'tot', FSCList.Title FROM t_PART INNER JOIN FSCList ON t_PART.FSC = FSCList.FSC group by FSCList.Title,
sum(case when v_ValidDate.ExpireDate > t_PART.ColorCodeDS then 1 else 0 end) as 'expired', sum(case when t_PART.colorcode is null then 1 else 0 end) as
'Not', sum(case when t_Part.colorcode = 'green' and v_ValidDate.ExpireDate < t_PART.ColorCodeDS then 1 else 0 end) as 'green', sum(case when
t_Part.colorcode = 'yellow' and v_ValidDate.ExpireDate < t_PART.ColorCodeDS then 1 else 0 end) as 'yellow', sum(case when t_Part.colorcode = 'orange' and
v_ValidDate.ExpireDate < t_PART.ColorCodeDS then 1 else 0 end) as 'orange', sum(case when t_Part.colorcode = 'red' and v_ValidDate.ExpireDate <
t_PART.ColorCodeDS then 1 else 0 end) as 'red', sum(case when t_Part.colorcode = 'unidentified' and v_ValidDate.ExpireDate < t_PART.ColorCodeDS then 1
else 0 end) as 'un', sum(case when t_Part.colorcode = 'excluded' and v_ValidDate.ExpireDate < t_PART.ColorCodeDS then 1 else 0 end) as 'ex' FROM
v_ValidDate RIGHT OUTER JOIN t_PART ON v_ValidDate.Color = t_PART.ColorCode RIGHT OUTER JOIN t_NHA ON t_PART.DPN = t_NHA.DPN
and t_PART.SiteCode = t_NHA.SiteCode where t_NHA.PL = 'PL114387-101' and t_NHA.SiteCode = 'NE' GROUP BY t_PART.FSC"
   

- Advertisement -