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
 IF statement in SQL

Author  Topic 

eem_2055
Yak Posting Veteran

69 Posts

Posted - 2008-05-15 : 09:40:39
how can I use If Statement given the following:
this is the situation
if Present Balance > 2500
then Control Amount = 2500

if Present Balance < 2500
then Control Amount = control amount

Balance Control Amount
2,000.00
2,500.00
3,000.00
4,500.00

What query can I use to get this table?
Balance Control Amount
2,000.00 2,000.00
2,500.00 2,500.00
3,000.00 2,500.00
4,500.00 2,500.00

Thanks,,:)




harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-05-15 : 09:48:38
[code]Select Balance, Case when Balance > 2500 then 2500 else balance as ControlAmount
from table[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-15 : 10:14:58
quote:
Originally posted by harsh_athalye

Select Balance, Case when Balance > 2500 then 2500 else balance end as ControlAmount
from table


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"


missed end clause
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-05-15 : 10:16:58
Thanks Visakh!

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -