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)
 Calculations with an SP

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-07-06 : 07:43:31
Tim writes "I need to build a stored procedures that takes two fields in a table, checks one for it's value (both fields are numbers/floats) =< 12 If it's less then 12 then use the acutal number. If it's more then 12 use only 12.

Field A = 45

Field B =< 12 If B <12 then Set B=B, if B is > 12 set B = 12

then Sum(a+b) as total.

I can't get the syntex right. It seemed simple enough.

Thanks for any suggestions."

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-06 : 08:04:03
Something like

Select Distinct A+ Case when B <12 then B else 12 end from yourtable



Madhivanan

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

- Advertisement -