Help Writing a Udf that get Number of "Years in a row"

  • Hello.

    I have a table (say orderlines) with orderrows,    There is a column that holds the "Year"  of the orderline.

    I like to write a  userdefine function that calculate how many years in a row that item has been sold from today and back.

     

    For examle :

    If I in the table have:

    ItemA    2020

    ItemA    2020

    ItemA  2019

    ItemA  2019

    ItemA  2019

    ItemA 2017

     

    The result is two year (since 2017 is not in a row)

     

    IF I have

    ItemB     2019

    ItemB     2019

    ItemB   2018

    ItemB   2018

     

    the result is 0  because it is not sold 2020

     

    How can I accomplish this?

  • I solved it  so forget my question

     

     

  • atleast post ur solution and not only "solved it", someoen might stumble upon this post and be like..

    yeah thanks for nothing

    I want to be the very best
    Like no one ever was

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

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