Skip to main content
edited tags
Link
deleted 66 characters in body
Source Link
Akina
  • 20.3k
  • 2
  • 19
  • 22

I am trying to carry forward the previous state of data wherever data is not available. For example, I have following data;

Month | Order | Amount
1     | Item1 | 100
1     | Item2 | 200 
1     | Item3 | 300
2     | NULL  | NULL
3     | Item4 | 100
4     | NULL  | NULL
5     | NULL  | NULL
6     | Item1 | 100
MonthOrderAmount
1Item1100
1Item2200
1Item3300
2NULLNULL
3Item4100
4NULLNULL
5NULLNULL
6Item1100

So in the above example I want to use 1st month's information to be carry forwarded as it is for 2nd month. Also since 3rd month's information is available then use it for the month 4 and 5. Hence the output will be following:

Month | Order | Amount
1     | Item1 | 100
1     | Item2 | 200 
1     | Item3 | 300
2     | Item1 | 100
2     | Item2 | 200 
2     | Item3 | 300
3     | Item4 | 100
4     | Item4 | 100
5     | Item4 | 100
6     | Item1 | 100
MonthOrderAmount
1Item1100
1Item2200
1Item3300
2Item1100
2Item2200
2Item3300
3Item4100
4Item4100
5Item4100
6Item1100

I am trying to carry forward the previous state of data wherever data is not available. For example, I have following data;

Month | Order | Amount
1     | Item1 | 100
1     | Item2 | 200 
1     | Item3 | 300
2     | NULL  | NULL
3     | Item4 | 100
4     | NULL  | NULL
5     | NULL  | NULL
6     | Item1 | 100

So in the above example I want to use 1st month's information to be carry forwarded as it is for 2nd month. Also since 3rd month's information is available then use it for the month 4 and 5. Hence the output will be following:

Month | Order | Amount
1     | Item1 | 100
1     | Item2 | 200 
1     | Item3 | 300
2     | Item1 | 100
2     | Item2 | 200 
2     | Item3 | 300
3     | Item4 | 100
4     | Item4 | 100
5     | Item4 | 100
6     | Item1 | 100

I am trying to carry forward the previous state of data wherever data is not available. For example, I have following data;

MonthOrderAmount
1Item1100
1Item2200
1Item3300
2NULLNULL
3Item4100
4NULLNULL
5NULLNULL
6Item1100

So in the above example I want to use 1st month's information to be carry forwarded as it is for 2nd month. Also since 3rd month's information is available then use it for the month 4 and 5. Hence the output will be following:

MonthOrderAmount
1Item1100
1Item2200
1Item3300
2Item1100
2Item2200
2Item3300
3Item4100
4Item4100
5Item4100
6Item1100
Source Link

Use previous state of data

I am trying to carry forward the previous state of data wherever data is not available. For example, I have following data;

Month | Order | Amount
1     | Item1 | 100
1     | Item2 | 200 
1     | Item3 | 300
2     | NULL  | NULL
3     | Item4 | 100
4     | NULL  | NULL
5     | NULL  | NULL
6     | Item1 | 100

So in the above example I want to use 1st month's information to be carry forwarded as it is for 2nd month. Also since 3rd month's information is available then use it for the month 4 and 5. Hence the output will be following:

Month | Order | Amount
1     | Item1 | 100
1     | Item2 | 200 
1     | Item3 | 300
2     | Item1 | 100
2     | Item2 | 200 
2     | Item3 | 300
3     | Item4 | 100
4     | Item4 | 100
5     | Item4 | 100
6     | Item1 | 100