Monday, March 19, 2012

Hi

I'm cuestion
how to update at all
this is my sentence
update Table1
set Total = sum(b.monto)
from Table1 a , Details b
Where a.numerCode = b.numerCode
the answer is : an aggregate may not apper in the set list of an Update
statement.
Thanks for you help.
ChreesHello, MJ
Try something like this:
update Table1 set Total = (
select sum(b.monto) from Details b
Where a.numerCode = b.numerCode
)
from Table1 a
where exists (
select * from Details b
Where a.numerCode = b.numerCode
)
or:
update Table1 set Total = isnull((
select sum(b.monto) from Details b
Where a.numerCode = b.numerCode
),0)
from Table1 a
Razvan|||Thanks
try Ok.
thank you for you help.
"Razvan Socol" escribió:

> Hello, MJ
> Try something like this:
> update Table1 set Total = (
> select sum(b.monto) from Details b
> Where a.numerCode = b.numerCode
> )
> from Table1 a
> where exists (
> select * from Details b
> Where a.numerCode = b.numerCode
> )
> or:
> update Table1 set Total = isnull((
> select sum(b.monto) from Details b
> Where a.numerCode = b.numerCode
> ),0)
> from Table1 a
> Razvan
>

No comments:

Post a Comment