Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.sqlserver.programming > #31313
| Newsgroups | microsoft.public.sqlserver.programming |
|---|---|
| Date | 2016-12-23 16:40 -0800 |
| References | <4e3f4200-45fa-45f6-9ec7-196f884c8d7c@googlegroups.com> |
| Message-ID | <8b8cc9e2-c714-4a46-bd50-bf1212a08527@googlegroups.com> (permalink) |
| Subject | Re: Select last column amongst group of columns where value>0 |
| From | maizesheng@gmail.com |
On Thursday, December 1, 2016 at 12:21:44 PM UTC-4, Mary Phelps wrote: > 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. Your presentation is not clear. For example row SiteID:101 Week5B:9 is greater than > 0 and if we assume that order starts from Week1A then it would be the last column with a value greater than zero.
Back to microsoft.public.sqlserver.programming | Previous | Next — Previous in thread | Find similar
Select last column amongst group of columns where value>0 Mary Phelps <icanhelp33@gmail.com> - 2016-12-01 08:21 -0800 Re: Select last column amongst group of columns where value>0 --CELKO-- <jcelko212@earthlink.net> - 2016-12-02 10:07 -0800 Re: Select last column amongst group of columns where value>0 maizesheng@gmail.com - 2016-12-23 16:40 -0800
csiph-web