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
GROUP BY WAC_JC_COST_DETAIL.Job_Number
Best as always,
Microsoft is conducting an online survey to understand your opinion of the Msdn Web site. If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site.
Would you like to participate?