Here the code I'm starting with doesn't work like this:
UPDATE mt
SET mt.action = 'A', mt.TQA = TRUE,
mt.OPID = 'SYS', mt.rc= 'DAR', mt.h='DAR'
WHERE EXISTS
(
SELECT mt.Account FROM mt AS pm
WHERE mt.Account = pm.Account
GROUP BY pm.Account, pm.[amount] + Nz(pm.[SFS],0)
HAVING (pm.[amount] + Nz(pm.[SFS],0) > 500)
);
I need the total amount and SFS for all instances of the account, where it is more than 500.
For example, if I have the following table
Account Amount SFS
123 350.00 0.00
123 125.00 125.00
123 350.00 0.00
123 125.00 125.00
234 1600.00 5.00
345 2.50 4.60
I have to get
123 1200.00
234 1605.00
What I get with the above code are different totals, not groups, which means they are not caught using> 500:
123 350.00
123 250.00
234 1605.00
Can anyone help? We have 5 people at a standstill.
source
share