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.
| Author |
Topic |
|
smithani
Starting Member
42 Posts |
Posted - 2007-06-05 : 15:19:46
|
| Hi,I have this update statement that works, it updates the totalamount to calc amount, but I want to update totalamount only when it is not equal to calcamt.I have tried many things but in vain.Can some one please help me.How do i use case statements to update only when totalamount!=calcamt.update cset totalamount= calcamtfrom Prepay c JOIN ( select sum(amt) as calcamt, payid from pay group by payid )b ON b.payid= c.payid where c.cust_no='somenum' |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-06-05 : 15:21:41
|
| update cset totalamount = case when totalamount <> calcamt then calcamt else totalamount endfrom ...._______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
smithani
Starting Member
42 Posts |
Posted - 2007-06-05 : 15:55:45
|
| Thank you thank you so much.I was trying != instead of <>, could that have been my problem and also I had nothing in my else just else end.thanks a bunch |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-06-05 : 15:57:05
|
| != should work too..._______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-06 : 09:49:50
|
quote: Originally posted by smithani Thank you thank you so much.I was trying != instead of <>, could that have been my problem and also I had nothing in my else just else end.thanks a bunch
You should have posted your case when ... query MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|