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
 General SQL Server Forums
 New to SQL Server Programming
 Sum

Author  Topic 

Shelly1
Starting Member

25 Posts

Posted - 2009-05-06 : 05:49:03
Hi, can anyone tell me how to sum a calculated field?

for eg:

[TurnExcessTime20] = (((Case when timeturn is not null and cast(datediff(s,Timeturn,TimeClear) as decimal)/60 between 20 and 360 then ((cast(datediff(s,Timeturn,TimeClear) as decimal)/60) - 20) else null end )))

THe above is the calculation needed to create a new field or data descripter called TurnExcessTime20, i need to sum that calculation now and i do not have the foggiest!

Thanks
Michelle

Mich

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-05-06 : 05:55:45
just put a SUM ( ) to enclose the case statement

[TurnExcessTime20] = SUM( < . existing case statement. .> )



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Shelly1
Starting Member

25 Posts

Posted - 2009-05-06 : 06:16:25
I knew it would be simple! could not see the wood from the Trees,
Many thanks
M

Mich
Go to Top of Page
   

- Advertisement -