• saxsena_sanjay (10/22/2014)


    Koen Verbeeck (10/22/2014)


    You can add a row number to each line with ROW_NUMBER(). Filter on non-zero quantities and get the minimum row number. Substract this from the maximum row number.

    hi Thanks. I have tested it and your idea works, just that it would be "Subtract the filtered minimum row number - 1 from the maximum. This forum rocks!

    Yeah, I was not sure if you had to subtract 1 from the minimum row number or not and didn't have time to test it all out.

    Glad your problem is solved.

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