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 |
Eithne
Starting Member
8 Posts |
Posted - 2004-08-30 : 12:05:48
|
Can anyone help with this sql query. Is it possible to include a select statement in the where of an update statement.I am trying to sum a number of fields together and when they are equal to zero and along with the other 'where' requirements i need to update the flag.E.GUpdate TABLE set FLAG='1'where(Select SUM(AMOUNT)from TABLEwhere SUM(AMOUNT) = 0.00and FLAG = '2'and ACC = '3') |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-30 : 12:17:18
|
something like this:update tset flag='1'from myTable t inner join (select id from myTable where FLAG = '2' and ACC = '3' group by id having SUM(AMOUNT) = 0) t1 on t.id = t1.id for real solution we need more info. like table structure and sample data -> create and insert into statementsGo with the flow & have fun! Else fight the flow :) |
|
|
|
|
|