473,402 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Count only counts all results and ignores criteria

Hello all

Run into a problem with a count query in access. It seems to count
either all the results or none depending on criteria even though

I have a query that selects the difference in seconds between two
times, I have managed to display these fine and even select ones below
500 seconds that show in a table.

When I group these by date and select all under 500 seconds again it
will count all the results or none.

Ie there would be 10 records in total 7 below 500s and 3 above 500s but
it would count the results as 10 even though without the aggregation it
would show 7 records in the result set.

Time in seconds is calulated by:
(DateDiff("s",[tblTimeRecords]![receivedTime],[tblTimeRecords]![repliedTime]))

any ideas?

Nov 13 '05 #1
2 1736
Stephen:

One approach would be to create a field to indicate whether the result is
above 500 or below and then have your query group on this field. You can
use an IIF statement to set the value for the field. For example:

IIF([Time]<=500, 1, 2)

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
"Stephen" <st***********@cwcom.co.uk> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Hello all

Run into a problem with a count query in access. It seems to count
either all the results or none depending on criteria even though

I have a query that selects the difference in seconds between two
times, I have managed to display these fine and even select ones below
500 seconds that show in a table.

When I group these by date and select all under 500 seconds again it
will count all the results or none.

Ie there would be 10 records in total 7 below 500s and 3 above 500s but
it would count the results as 10 even though without the aggregation it
would show 7 records in the result set.

Time in seconds is calulated by:
(DateDiff("s",[tblTimeRecords]![receivedTime],[tblTimeRecords]![repliedTime]))

any ideas?
Nov 13 '05 #2
On 10 Jun 2005 04:42:25 -0700, Stephen wrote:
Hello all

Run into a problem with a count query in access. It seems to count
either all the results or none depending on criteria even though

I have a query that selects the difference in seconds between two
times, I have managed to display these fine and even select ones below
500 seconds that show in a table.

When I group these by date and select all under 500 seconds again it
will count all the results or none.

Ie there would be 10 records in total 7 below 500s and 3 above 500s but
it would count the results as 10 even though without the aggregation it
would show 7 records in the result set.

Time in seconds is calulated by:
(DateDiff("s",[tblTimeRecords]![receivedTime],[tblTimeRecords]![repliedTime]))

any ideas?


Try:
Sum(IIf([TimeField]<=500,1,0))
or
Sum(IIf([TimeField]>500,1,0))

I placed =500 in with the < 500 group.
Change it to the >500 group if you wish.

If the query is used as the recordsource for a report, I would place
the above expressions in unbound controls in the report, and not
bother in the query.
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Paxton | last post by:
Hi, I'm trying to display the total page views per page within a given date range, but the correct SQL is seemingly beyond me. I get the correct result with a straightforward Group By and Count...
2
by: Anthony Robinson | last post by:
Is there any way to do multiple select count(*) statements in a SQL query. I have a table that I want to get the counts of rows matching certain criteria. For example: SELECT COUNT(1) AS...
4
by: Matthew Groch | last post by:
Hi all, I've got a server that handles a relatively high number of concurrent transactions (on the magnitude of 1000's per second). Client applications establish socket connections with the...
1
by: John | last post by:
Hi I have a field that can have either A, B or C as its value. I need to write a query that will return the number of A's, B's & C's in the field X for a given criteria and then the total...
1
by: TechnoPup | last post by:
Greetings, I am very new to working with databases, and I am not sure how to go about structuring the query I need. What I have is an Access database with approx. 400,000 records in 5 fields. ...
4
by: Chris | last post by:
Can't seem to figure out how to do this and have been reading for some time now...... I want to select a row count from a table name in SYSTABLES. This statement does not return what I needed,...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
3
by: NarutoFanatic | last post by:
Hi, I need help. i'm having trouble with selecting the row counts using the vb macro. I need to select the row count of records with a given criteria in one column in excel. I've tried using filter...
3
by: waynejr25 | last post by:
can anyone debug my program and get it to run. #include <fstream> #include <iostream> #include <string> #include <cstdlib> #include <map> using namespace std;
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.