Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

distinguishing years

Status
Not open for further replies.

alh1002

Technical User
Mar 27, 2006
41
US
I am summarizing daily table into monthly and yearly tables

the following query works within a given year: but if you multiple years it fails (i.e. it doesn't distinguish between Suggestions?

SELECT A.ladder_date, A.BOM, A.NAV, A.gMTDRT, A.gMTDPER
FROM dailySummary AS A INNER JOIN (
SELECT Month([ladder_date]), MAX([ladder_date]) AS LastDay FROM dailySummary GROUP BY Month([ladder_date])
) AS L ON A.ladder_date = L.LastDay


 
You should group by year also, not only month

SELECT A.ladder_date, A.BOM, A.NAV, A.gMTDRT, A.gMTDPER
FROM dailySummary AS A INNER JOIN
(SELECT Year([ladder_date]), Month([ladder_date]),
MAX([ladder_date]) AS LastDay
FROM dailySummary
GROUP BY Year([ladder_date]), Month([ladder_date])) AS L
ON A.ladder_date = L.LastDay

But this post should be in forum701.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top