• headmanracer (12/26/2012)


    I need some help with SQL to capture transactions posted 90 days prior to month end for the last 12 months. I have a table named TRANSACTIONS and a field named TRANSACTIONS.POST_DATE and also a calendar table named VOCAB.DATE_MM_DD_YYYY where these are joined based on TRANSACTIONS.POST_DATE = VOCAB.DATE_MM_DD_YYYY.

    For example where the month end is 11/30/2012 I need to sum transactions posted 9/2/2012 - 11/30/2012 (90 days) and where month end is 10/31/2012 I need to sum transactions posted 8/3/2012 - 10/31/2012 (90 days). I need this for a rolling 12 months, and I need to automate this query.

    Thanks in advance.

    Hi and welcome to SSC. It is impossible to provide any assistance based on what you have posted. There just simply are not enough details. You need to provide ddl (create table statements), sample data (insert statements) and desired output based on your sample data.

    Take a look at the first link in my signature for best practices when posting questions.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/