how to get data where value is null

  • Hello,

    I have a table with data like below

    idvalue

    12

    24

    36

    4NULL

    58

    6NULL

    7NULL

    812

    915

    10NULL

    1120

    12NULL

    and i need output like below

    idvalue

    12

    24

    36

    46

    58

    68

    78

    812

    915

    1015

    1120

    1220

    please help..

  • I managed to write some code that doesn't use a cursor, so hooray for performance 🙂

    SELECT

    ID= tmp.ID

    ,Value= t3.[Value]

    FROM

    (SELECT t1.[ID]

    ,MaxID = MAX(t2.ID)

    FROM[dbo].[Test] t1

    INNER JOIN[dbo].[Test] t2 ON [t1].[ID] >= [t2].[ID] AND t2.[Value] IS NOT NULL

    GROUP BY t1.[ID]) tmp

    INNER JOIN [dbo].[Test] t3 ON tmp.[MaxID] = t3.[ID]

    Please read the link in my signature on how to post questions and sample data. It will make the life of people who are trying to answer your question easier.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Thank You Very Much...

    Its so helpful to me..

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply