Rotation for days in account receivable

  • Hi all
    I would like to perform an operation, be it a function or store procedure ... that can return me on the day of rotation of the account receivable. Currently I have it in a function with a cursor, but it lasts a lot to return the value.
    I explain in detail to see how you can help me with this:
    With this I have 2 tables:
    1) The account receivable from the client to date

    2) The Sales generated by the customer in the different months.

    With this I must determine the rotation of the account receivable per day. Based on a formula that has been determined, we take the account receivable to date, and calculate it by sales (but this calculation would be going through the months backwards, until finding the amount that resembles the account receivable). As they are fixed, I will only be passing the client, the balance of the account receivable and the sales of the months or days prior to the date that the account receivable has and this will return me the days.

    I hope you can help colleagues, I'll thank you.

  • DDL, sample data and expected results will be helpful and get you the results you need

    For better, quicker answers, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • What you're looking to approximate is an aged receivable report.  I agree with Mike as to needing DDL, but it would be best to NOT leverage he pivoted sales data for this, since it will substantially complicate the processing.  Do you have actual access to the detail underlying the pivot?

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Mike01 - Tuesday, January 22, 2019 9:32 AM

    DDL, sample data and expected results will be helpful and get you the results you need

    Thanks!!! The solution Dynamics Pivot!

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

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