All Forums UDA
marcmc 112 posts Joined 12/05
16 Jan 2008
Aggregation

UPDATE marc SET m2 = sum(m1) + sum(m2) WHERE m1 = 1;What is a practical solution to this?

dnoeth 4628 posts Joined 11/04
16 Jan 2008

Hi Marc,strange update but there it is:UPDATE marc FROM (SELECT SUM(m1) + SUM(m2) AS x FROM marc WHERE m1 = 1) dtSET m2 = dt.x WHERE m1 = 1;Dieter

Dieter

marcmc 112 posts Joined 12/05
17 Jan 2008

Thanks."Strange" - Yes I thought so too.So I thought why not test it anyway as I didn;t think it was valid.I have an idea on paper from someone else(that I don't fully understand yet hence this post) and they documented this approach.Just to compare notes, Why do you consider it to be strange?

dnoeth 4628 posts Joined 11/04
17 Jan 2008

Hi Marc,it's strange, because the update is based on two columns and one of those is also used within the where-condition.What kind of summable information is hidden within that column?I simply can't imagine any real usage for that :-)m1 m21 101 201 30will result in m1 m21 631 631 63(1+1+1) + (10+20+30) -> 63Dieter

Dieter

You must sign in to leave a comment.