0

I'm trying to summarize parts of a delivery in terms of weight (and also value) but I fail to make it work when I group by deliveryNo which is what I want/need. I also need to group by type to get correct summarizations in each columns which causes extra rows and I need 1 row per deliveryNo and I have tried several solutions with case and subequeries but I'm not managing to get this correct.

Example below. To clarify, the type is a value connected to each row from another table, and weight is also from a separate table but the tables are linked with an articleNo.

deliveryNo type amount weight value
123 1 5 1 25
123 2 10 1 26
123 3 2 2 24
123 4 8 2 20
123 5 6 3 10

What I want to achieve is this: (settling for weight but the value will be used, but I reckon the principal will be the same)

deliveryNo weighttype1 weighttype2 weighttype3 weightRest
123 5 10 4 34
Stu
  • 30,392
  • 6
  • 14
  • 33
  • Can you please explain the logic also? Why weighttype3 is 4 and weightRest is 34. – Ankit Bajpai Feb 27 '22 at 12:43
  • Sorry, the summarized weight is the amount x weight and I want each type of 1,2 and 3 summarized separately in 1 column each and all other types summarized together in a fourth column. – Danny1981 Feb 27 '22 at 13:46

0 Answers0