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!

WorkUnit totals by Month via a date range 1

Status
Not open for further replies.

netrusher

Technical User
Feb 13, 2005
952
US
Below is the code I have for a query that shows me the number of WorkUnits via a date range that is put in via calendars. This works great. It gives me one total for the date range. What I would like to be able to do is see the WorkUnit totals by month via a date range. If I put in the date range: Jan 1-April 30 I would like to get four WorkUnit totals instead of one. I would like to see the WorkUnit totals for each month. Can anyone assist with this? I asked a similar question like this yesterday but he SQL for this code is different and I have not been able to figure out how to apply yesterday's answer to this one. I have tried everything I can think of to no avail. I posted this code on my post from yesterday but think I should have made this anew post. If it should not be a new post I am sorry. HELP!

Code:
SELECT 'Total Work Units' AS FaultCategory, Count([WorkUnit]) AS [WU Totals]
FROM [Select Distinct [WorkUnit]
         FROM WorkUnitsFaultsMainTBL
            WHERE BuildID IN ("G004","E818","N005","F813","D024","C879") AND
            PossibleCause NOT IN ("Out of Stock") AND
                [TodaysDate] BETWEEN [Forms]![Queries_ReportsFRM]![StartDateTxt] AND
                                        [Forms]![Queries_ReportsFRM]![EndDateTxt]]. AS vTbl;
 
SELECT 'Total Work Units' AS FaultCategory, [Month], Count(*) AS [WU Totals]
FROM (SELECT DISTINCT Format(TodaysDate,'yyyy-mm') AS [Month], WorkUnit
FROM WorkUnitsFaultsMainTBL
WHERE BuildID IN ('G004','E818','N005','F813','D024','C879')
AND PossibleCause <> 'Out of Stock'
AND (TodaysDate BETWEEN [Forms]![Queries_ReportsFRM]![StartDateTxt] And [Forms]![Queries_ReportsFRM]![EndDateTxt])) AS vTbl
GROUP BY [Month]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How about a Group By on Month([TodaysDate])?
 
Thanks again PH,

I tried everything I new to do. That is a big help and works great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top