I have a dataset on sql server, for example:
ID ID_Invoice Article Quantity Status 1 10 carrot 10 null 2 10 carrot 5 C 3 10 onion 8 null 4 10 onion 4 C 5 11 tomato 20 null 6 11 tomato 18 C 7 11 onion 2 null 8 11 onion 1 C
This means that the client ordered 10 carrots and 8 onions (one account each), but actually received only 5 carrots and 4 onions. If the status is null, then this is the original value, if the status is C, then the quantity is adjusted
I need to create a table like
ID ID_Invoice Article Quantity 1 10 carrot -5 2 10 onion -4 3 11 tomato -2 4 11 onion -1
which shows the difference between the ordered quantity and the real value in each account. I do not know how to start. Any help is greatly appreciated :)
source share