Sql case that will use a current table

Posted by Dana Ezer on Stack Overflow See other posts from Stack Overflow or by Dana Ezer
Published on 2014-08-25T10:16:04Z Indexed on 2014/08/25 10:19 UTC
Read the original article Hit count: 240

Filed under:
|
|

I have an sql statement that returns this result below,and I want that the num will drag the latest(by date) num that is not null. I can't get it right. I want to add somthing like this:

case
when num is null then max(num where date<my_date)

my result now:

Date num 1.1 0 2.1 1 3.1 NULL 4.1 NULL 5.1 4

what I want:

Date num 1.1 0 2.1 1 3.1 1 4.1 1 5.1 4

© Stack Overflow or respective owner

Related posts about sql

Related posts about max