troubleshooting Question

SQL query - if result blank keep the last result

Avatar of LukeWygas
LukeWygas asked on
SQL
7 Comments1 Solution365 ViewsLast Modified:
I have a query with a calculated column (CompRest).  CompRest will either be zero or a figure.  The data is sorted in date order (I do have a column trxSeq which is sequential if that helds).  I need another column (CompRestCum) to be equal to CompRest, unless CompRest is zero, in which case I need it to be the last none zero figure.  For example of the data see below.

Comp Rest               CompRestCum
0                              0
0                              0
3                              3
0                              3
0                              3
7                              10
0                              10
0                              10
3                              13
0                              13
0                              13

So it is not cumulative, it simply keeping the last none zero.  Thanks for your help.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros