Count of material based on another column

Database
Enthusiast

Count of material based on another column

HI All,
We have a table in below format
material_id ; plant ; weekNo XA
1234; 700 ; W1; -40
1234 701 W2 -10
1234 702 W3 100
1234 700 W4 -150
Now the requirement is
a)Count of material having sum of column XA < 0 for Week 1 and Week 2
b)Count of material having sum of column XA < 0 for Week 2 and Week 3 and so on...
Final table should be like below :
material_id plant weekNO XA Wk1-2 Wk2-3 Wk3-4 Wk4-5
1234 700 W1 -40 2
1234 701 W2 -10 0
1234 702 W3 100 1
1234 701 W4 -150 1
Please let me know how we can achieve the above scenario.