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)
 Calculate view with SUM function

Author  Topic 

eugz
Posting Yak Master

210 Posts

Posted - 2005-10-12 : 09:42:04
Hi All.
I have problem to fix a view. It looks like:
SELECT   Date_P, -SUM(is not null [Result]) AS Complete, 
-SUM(is null [Result]) AS [Not Complete]
FROM dbo.Prob
GROUP BY Date_P

Message says: "Incorrect syntax near the keyword 'is'." What is correct decision?
Thanks.

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2005-10-12 : 09:45:13
how do you sum null values? do you mean count?

select date_p, sum(case when result is null then 0 else 1 end) as complete, sum(case when result is null then 1 else 0 end) as notcomplete
from prob
group by date_p

Jay White
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-12 : 09:45:17
Try this

SELECT Date_P, -SUM(Case When [Result] is not null then [Result] end) AS Complete,
-SUM(Case When [Result] is null [Result] end) AS [Not Complete]
FROM dbo.Prob
GROUP BY Date_P


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-12 : 09:46:22
Just 4 seconds

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -