Help with max(date) selection

Answered Help with max(date) selection

  • Monday, August 20, 2012 5:50 PM
     
     

    Hello,

    I need help with sql query max(date) in select statement ( using ms sql server 2008 r2)

    I have a query that sums up transaction costs for each job and I am trying to add a last transaction date for each of those jobs, ie (max_transaction_date).

    I am trying just insert the Max() function into existing code but not getting the results.  I could really use so pointers about how to get this done.

    If I need to run the max() statement as a separate sub select and join it to transaction sum, no problem. Just need help in getting the latest transaction date for each job to show.

    ==========================================================

    SELECT  distinct WAC_JC_COST_DETAIL.Job_Number AS WAC_JOB_NUMBER
                     , MAX(WAC_JC_COST_DETAIL.Tran_Date_Text) as Max_Tran_Date -- >FYI<Tran_Date_Text is a 'Date' field

                     ,SUM(WAC_JC_COST_DETAIL.Tran_Amount) AS Sum_Tran_Amount

    FROM  WAC_JC_COST_DETAIL
    GROUP BY WAC_JC_COST_DETAIL.Job_Number

    ==========================================================

    Best as always,

    Vic_M

All Replies

  • Tuesday, August 21, 2012 12:03 AM
     
     Answered
    I fixed this issue... My original code was correct and had nothing to do why the data was not showing on the query.
    • Marked As Answer by Vic_M Tuesday, August 21, 2012 12:03 AM
    •