create trigger trOrders_insupd on orders FOR INSERT, UPDATE
as
declare @goodthreshhold INT
declare @totalValue INT
declare @cusid INT
set @goodthreshhold = 1000
set @cusid = inserted.cusid
if update (ordertotal)
select @totalValue = sum(ordertotal)
from orders where o.cusid=@cusid
group by ordertotal
if (@totalValue > @goodthreshhold)
update customers set type='Good' where cusid=@cusid