Here is code
select giftid,attrtype,
sum(case when gifttype in ('b','g','y') then giftjntamt else 0 end)as Gifts,
sum(case when gifttype = 'c' then giftjntamt else 0 end)as Credits
from gifts with(readpast)
left outer join attribute_VIEW with(readpast)
on attrid=giftid
where gifttype in ('b','c','g','y')
and gifteffdat >='2009-07-01'
group by giftid,attrtype
having sum(giftjntamt)>=250
sample data
giftid attrtype gifts credits
11111 Null 250 0
11211 SON24 355 122
12544 Null 125 125
I need to update all records in this query to populate SON24 in the attrtype field because all records have giving or credits of 250 or more. The field that needs updating is the attribute_VIEW field. The qualifying field is the gift field. So I need to update the attribute_VIEW table with SON24. Does the update statement go before or after the above query and how would I update when there are multiple tables involved
select giftid,attrtype,
sum(case when gifttype in ('b','g','y') then giftjntamt else 0 end)as Gifts,
sum(case when gifttype = 'c' then giftjntamt else 0 end)as Credits
from gifts with(readpast)
left outer join attribute_VIEW with(readpast)
on attrid=giftid
where gifttype in ('b','c','g','y')
and gifteffdat >='2009-07-01'
group by giftid,attrtype
having sum(giftjntamt)>=250
sample data
giftid attrtype gifts credits
11111 Null 250 0
11211 SON24 355 122
12544 Null 125 125
I need to update all records in this query to populate SON24 in the attrtype field because all records have giving or credits of 250 or more. The field that needs updating is the attribute_VIEW field. The qualifying field is the gift field. So I need to update the attribute_VIEW table with SON24. Does the update statement go before or after the above query and how would I update when there are multiple tables involved