G
Guest
I have the following SQL for my query but I want to have the user be able to
select the year only for this query. How would I write this into my SQL
statement?
SELECT DISTINCTROW tblNCMR.DiscrepancyCode,
Format$([tblNCMR].[DateCreated],'mmmm yyyy') AS [DateCreated By Month],
Sum(tblNCMR.TotalCost) AS [Sum Of TotalCost], Count(*) AS [Count Of tblNCMR],
Month([DateCreated]) AS MonthNum, tblDiscrepancyCodes.[Code Description]
FROM tblDiscrepancyCodes INNER JOIN tblNCMR ON tblDiscrepancyCodes.Code =
tblNCMR.DiscrepancyCode
GROUP BY tblNCMR.DiscrepancyCode, Format$([tblNCMR].[DateCreated],'mmmm
yyyy'), Month([DateCreated]), tblDiscrepancyCodes.[Code Description],
Year([tblNCMR].[DateCreated])*12+DatePart('m',[tblNCMR].[DateCreated])-1
ORDER BY Month([DateCreated]);
select the year only for this query. How would I write this into my SQL
statement?
SELECT DISTINCTROW tblNCMR.DiscrepancyCode,
Format$([tblNCMR].[DateCreated],'mmmm yyyy') AS [DateCreated By Month],
Sum(tblNCMR.TotalCost) AS [Sum Of TotalCost], Count(*) AS [Count Of tblNCMR],
Month([DateCreated]) AS MonthNum, tblDiscrepancyCodes.[Code Description]
FROM tblDiscrepancyCodes INNER JOIN tblNCMR ON tblDiscrepancyCodes.Code =
tblNCMR.DiscrepancyCode
GROUP BY tblNCMR.DiscrepancyCode, Format$([tblNCMR].[DateCreated],'mmmm
yyyy'), Month([DateCreated]), tblDiscrepancyCodes.[Code Description],
Year([tblNCMR].[DateCreated])*12+DatePart('m',[tblNCMR].[DateCreated])-1
ORDER BY Month([DateCreated]);