473,396 Members | 1,879 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,396 software developers and data experts.

Is this possible in a query?

Pea
Is it possible to get the average in a query where I have multiple
criteria?
Here's an abbreviated example of the query in design view:

Fields: USERID DATE TIME ID_TYPE
Criteria: <>JoeSchmo <>*2003 <7AM <>this and <>that
Criteria: <>JoeSchmo <>*2003 7-9AM <>this and <>that
Criteria: <>JoeSchmo <>*2003 9-11AM <>this and <>that

Question: is it possible to get a total count of the number of rows
that meet each criteria and also add a column with an expression to
get the average from each criteria compared with the total row count
in the whole table? Or can this be done easier in a report or form?

Any hints would be greatly appreciated.

Thanks,
Tara
Nov 13 '05 #1
3 1619
Pea wrote:
Is it possible to get the average in a query where I have multiple
criteria?
Here's an abbreviated example of the query in design view:

Fields: USERID DATE TIME ID_TYPE
Criteria: <>JoeSchmo <>*2003 <7AM <>this and <>that
Criteria: <>JoeSchmo <>*2003 7-9AM <>this and <>that
Criteria: <>JoeSchmo <>*2003 9-11AM <>this and <>that

Question: is it possible to get a total count of the number of rows
that meet each criteria and also add a column with an expression to
get the average from each criteria compared with the total row count
in the whole table? Or can this be done easier in a report or form?

Any hints would be greatly appreciated.

Thanks,
Tara


You can start off with a query and build off of that one if needed.

Qyery/New/Design. Add your table then close.

Drag UserID, Date, Time (3 times) Time1...Time3, And IDType to the
In the criteria enter
<>"JoeSchmo"
under UserID.

I'll assume the date is a value that stores m,d,y. So enter
<>Year(2003)
under Date

In Time1 to time3 it should look like
Time1 : Time
Time2 : Time
Time3 : Time
in the data field row. In the criteria enter
<#7:00:00# for Time1
Between #7:00# And #8:59:59# for Time2
Between #9:00# And #10:59:59# For Time3

Now make this a Totals Query. From the menu, View/Totals

GroupBy should be assigned to UserID and IDType
Count should be assigned to Time1,2,3
Where should be assigned to the date...unless you want to group on the date.

Save and Run.

Now you can create another query that calls this one and average the
counts or you can use the above query in a report and calc the average
in a textbox's control source. Ex:
=(Time1 + Time2 + Time3) /3

Note I used / 3. You can also use \ 3 too. Here's an example of both
? 100/3
33.33333
? 100 \ 3
33

The \ gives an integer value.


Nov 13 '05 #2
Pea
Salad <oi*@vinegar.com> wrote in message news:<1B****************@newsread3.news.pas.earthl ink.net>...
You can start off with a query and build off of that one if needed.

Qyery/New/Design. Add your table then close.

Drag UserID, Date, Time (3 times) Time1...Time3, And IDType to the
In the criteria enter
<>"JoeSchmo"
under UserID.

I'll assume the date is a value that stores m,d,y. So enter
<>Year(2003)
under Date

In Time1 to time3 it should look like
Time1 : Time
Time2 : Time
Time3 : Time
in the data field row. In the criteria enter
<#7:00:00# for Time1
Between #7:00# And #8:59:59# for Time2
Between #9:00# And #10:59:59# For Time3

Now make this a Totals Query. From the menu, View/Totals

GroupBy should be assigned to UserID and IDType
Count should be assigned to Time1,2,3
Where should be assigned to the date...unless you want to group on the date.

Save and Run.

Now you can create another query that calls this one and average the
counts or you can use the above query in a report and calc the average
in a textbox's control source. Ex:
=(Time1 + Time2 + Time3) /3

Note I used / 3. You can also use \ 3 too. Here's an example of both
? 100/3
33.33333
? 100 \ 3
33

The \ gives an integer value.


Thank you, Salad. I got as far as the Save and Run part. It prompted
me for a TIME parameter. I tried just entering the field as it is in
the table and then it ran but returned no rows. I'll keep working out
this method. It should work this way.
Nov 13 '05 #3
Pea wrote:
Salad <oi*@vinegar.com> wrote in message news:<1B****************@newsread3.news.pas.earthl ink.net>...
You can start off with a query and build off of that one if needed.

Qyery/New/Design. Add your table then close.

Drag UserID, Date, Time (3 times) Time1...Time3, And IDType to the
In the criteria enter
<>"JoeSchmo"
under UserID.

I'll assume the date is a value that stores m,d,y. So enter
<>Year(2003)
under Date

In Time1 to time3 it should look like
Time1 : Time
Time2 : Time
Time3 : Time
in the data field row. In the criteria enter
<#7:00:00# for Time1
Between #7:00# And #8:59:59# for Time2
Between #9:00# And #10:59:59# For Time3

Now make this a Totals Query. From the menu, View/Totals

GroupBy should be assigned to UserID and IDType
Count should be assigned to Time1,2,3
Where should be assigned to the date...unless you want to group on the date.

Save and Run.

Now you can create another query that calls this one and average the
counts or you can use the above query in a report and calc the average
in a textbox's control source. Ex:
=(Time1 + Time2 + Time3) /3

Note I used / 3. You can also use \ 3 too. Here's an example of both
? 100/3
33.33333
? 100 \ 3
33

The \ gives an integer value.

Thank you, Salad. I got as far as the Save and Run part. It prompted
me for a TIME parameter. I tried just entering the field as it is in
the table and then it ran but returned no rows. I'll keep working out
this method. It should work this way.


OK. I'm not sure what your time field is called.

Also. The date field should have an expression with criteria. Ex:
DateYear : Year(date()
with the criteria
<>2003
Don't use the Year(2003) that I initially supplied.

If your field is called Time, then it should be Time. Lets say it is
called TimeOfCall. Then it should be something like
Time1 : TimeOfCall
Time2 : TimeOfCall
Time3 : TimeOfCall
with the criteria listed initially.

I'm sure you are close.

Nov 13 '05 #4

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

Similar topics

1
by: Frank Maestas | last post by:
Hello, I have been trying to figure this out but no luck. Lets say I have a query that searches for people living in Colorado. That results in a list on a "results.php" page. Now I want to...
22
by: Robert Brown | last post by:
suppose I have the following table: CREATE TABLE (int level, color varchar, length int, width int, height int) It has the following rows 1, "RED", 8, 10, 12 2, NULL, NULL, NULL, 20...
4
by: sah | last post by:
I need some help with the following query: DECLARE @SRV VARCHAR(20), @date smalldatetime SET @SRV = (select @@servername) SET @date = '20040901' select Srv_Name = @SRV, DB_Name = 'DB_NAME',...
3
by: Jonathan | last post by:
Hi all! For a match schedule I would like to find all possible combinations of teams playing home and away (without teams playing to themselves of course). I now the simple version works...
4
by: wnstnsmith | last post by:
Dear all, Suppose there is a table whose records contain a textfield TXT, and a query that returns a subset of that table. Is it possible to have that query return all the TXT-fields gathered...
5
by: Chris Ochs | last post by:
It doesn't currently seem possible to switch between different users using SET SESSION AUTHORIZATION. If I log in as the superuser and switch to another user that works, but if I then switch to a...
2
by: jim Bob | last post by:
Hi, I have a query with the criteria of (!..) Or !.. When I provide the value from qmylist, a second pop up appears waiting for the value from lstResults. If I enter nothing and click ok, it...
0
by: hdogg | last post by:
I am using oracle with php. I am trying to accomplish a left outer join. Here are the 3 queries. Query 1, contains all the data on the left the will show up with data on the right. Query 1 =...
2
by: DuncanIdaho | last post by:
Hi Apologies if this is similar to a (very) recent post. I was wondering if it is possible to execute an update query that contains a select statement on an MS access 2000 database. I have...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.