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

Query with counts for Chart in report

Status
Not open for further replies.

PeterDuthie

Programmer
Mar 14, 2001
29
0
0
GB
Hello Everyone. I need to get back two values from a query - 1. the total number of rows in a table and 2. the number of "incidents" which have been "signed off" (i.e.) dealt with successfully within 48 hrs. The two values are intended for a pie chart. Here's what I've got:

SELECT Count([T-incidents].[Signed off]) AS [Closed within 48 hrs]
FROM [T-incidents]
WHERE ([T-incidents].[Date of incident] + 2) >= [T-incidents].[Signed off];

How can I get the query to return the total number of incidents.

Thanks again to everyone who reads this.

(I'm cross posting this to the "Reports" forum - If I'm not supposed to do this please let me know)

Cheers,
Peter
 
Try:

SELECT Count(*) AS Total, (SELECT Count([T-incidents].[Signed off]) AS [Closed within 48 hrs]
FROM [T-incidents]
WHERE ([T-incidents].[Date of incident] + 2) >= [T-incidents].[Signed off]) FROM [T-incidents];

HTH

PsychPt@Hotmail.com
 
Very good Psychpt - this works perfectly. I see that DCount helps here too.

Cheers,
Peter
 
you're welcome.
I try to stay away from the Dfunctions, they say it's not as efficient.
 
Hello again Psychpt. You're obviously way ahead of me on SQL. Do you have a book recommendation? I have the excellent Access 2000 Developer's Handbook set but a more detailed discussion (with worked examples?) would be really useful to me.

Cheers,
Peter
 
Sorry, I don't have any recommendations maybe someone else here might be able to help you with that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top