Mary Phelps
2016-12-01 16:21:39 UTC
Here is data in my table
SiteId Week1A Week1B Week2A Week2B Week3A Week3B Week4A Week4B Week5A Week5B
101 0 8 7 9 0 6 0 9 0 9
288 8 8 0 7 0 7 0 8 6 6
468 1 8 6 9 8 6 0 9 0 9
768 0 8 0 7 0 7 6 8 0 6
I want a query that will look at all week1a,week2a,week3a,week4a,week5a and so forth
then figure out which is the last column which has value greater than 0 for example SiteId 101 It is Week2A. SiteId 288 it is Week5A. SiteId 468 week3A.
then after the last column is figured out sum up values of weeks remaing after that so for example siteid101 last column is week2a so i want a sum of week3b,week4b and week5b.
SiteId Week1A Week1B Week2A Week2B Week3A Week3B Week4A Week4B Week5A Week5B
101 0 8 7 9 0 6 0 9 0 9
288 8 8 0 7 0 7 0 8 6 6
468 1 8 6 9 8 6 0 9 0 9
768 0 8 0 7 0 7 6 8 0 6
I want a query that will look at all week1a,week2a,week3a,week4a,week5a and so forth
then figure out which is the last column which has value greater than 0 for example SiteId 101 It is Week2A. SiteId 288 it is Week5A. SiteId 468 week3A.
then after the last column is figured out sum up values of weeks remaing after that so for example siteid101 last column is week2a so i want a sum of week3b,week4b and week5b.