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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with query

Status
Not open for further replies.

svdoerga

Technical User
Apr 28, 2011
26
0
0
US
I have a form to view data summaries. Using controls, where the user inputs 'from' and 'to' dates, a query is generated to retrieve data and display it on a subform in datasheet view.

The table I'm retrieving data from looks like this:
Receivement(ReceivementID(PK,autoinc nr), ReceivedDate(date), CaseClosed(bool)....)

What I want to see is 3 columns: 1 - month, 2 - number of records, 3 - number of records where CaseClosed is true.

I need a query that retrieves the data like this, but I don't really know how to do it.

What I have managed so far:

Code:
SELECT Count(Receivements_Query.ReceivementID) AS CountOfReceivementID, Format([ReceivedDate],"mmm") AS Month
FROM Receivements_Query
GROUP BY Receivements_Query.CaseClosed, Format([ReceivedDate],"mmm"), Month([ReceivedDate])
HAVING (((Receivements_Query.CaseClosed)=False))
ORDER BY Month([ReceivedDate]);

This shows the number of records per month, but I fail when I want to add a third column that shows the number of records where CaseClosed is true.

It almost seems like the 3rd column should be a seperate query, but I don't know how I can correctly combine 2 queries to get what I need.

Any suggestions?
 
SumCaseClosed:sum(iif(CaseClosed=-1,1,0))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top