473,508 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to do this using MS ACCESS

I am producing a report that requires me, among many other things, to
calculate the average contracts for about 1000 companies during the yr
2003. The "quirk" is that all the companies do not have the same
number of months. When using DB2 the below code counts the average
contracts of each group for 2003. What code can I use in MS ACCESS to
produce the same result?

SELECT

COMPANY_NAME,
SUM(CONTRACTS)/COUNT(DISTINCT FIRST_DAY_OF_MONTH) contracts

FROM TABLE
Thanks
Nov 12 '05 #1
2 2489
Instead of expecting us to read DB2 SQL, could you just state the problem a
little more clearly? Access has Totals Queries with Group By and Avg, so I
suspect not only can Access do what you want, but do so easily without your
actually having to write your own SQL. There's a dandy Query Builder.

Specifically I'm not quite sure I know what you mean by "calculate the
average contracts for ... during the yr" and "... do not have the same
number of months".

Larry Linson
Microsoft Access MVP

"Mark" <mf******@hotmail.com> wrote in message
news:c8**************************@posting.google.c om...
I am producing a report that requires me, among many other things, to
calculate the average contracts for about 1000 companies during the yr
2003. The "quirk" is that all the companies do not have the same
number of months. When using DB2 the below code counts the average
contracts of each group for 2003. What code can I use in MS ACCESS to
produce the same result?

SELECT

COMPANY_NAME,
SUM(CONTRACTS)/COUNT(DISTINCT FIRST_DAY_OF_MONTH) contracts

FROM TABLE
Thanks

Nov 12 '05 #2
"> Specifically I'm not quite sure I know what you mean by "calculate
the
average contracts for ... during the yr" and "... do not have the same
number of months"."

First I would like to thank you for responding to my question and
appologize for my lack of clarity. I have been using DB2 on a
mainframe for about 3 years now at work.(I am an actuary for an
insurance company). Recently I had a OBDC driver installed on my PC. I
have never used ACCESS before so I thought this might be a good
oportunity to learn it. Lets say that I need to count the average
number of monthly contracts for Wal-Mart("contracts" are the insured
individuals or families.) Wal-Mart has been with my company for the
entire year and this is October so I have 10 months of contracts to
count/average. I add up the number of contracts for each month, which
fluctuates, and divide by the number of months to get an average. If
all the 100 or so groups had a full 10 months of contracts it would be
simple. I would just divide the sum for each group by 10. The first
part of the problem arises when a group like United Air or Food Lion
comes on board in April or May. In this case I do not have 10 months
of data so I cant just divide by 10. I have to divide by 5 or 4
months respectively. The second part of the problem is that each group
can have thousands of entries on the DB2 table that I am hitting. To
count the months I took advantage of the fact that every month has a
1st day. Jan 1st, Feb 1st....Oct 1st. I count the number of distinct
1st days of each month and divide it into the total number of
contracts. This simple technique gives me accurate results when using
DB2. More about the report: The report is simple in description but
very difficult in practice(the story of my life) I am looking at all
the monies we charge a group(admin fees) and all the monies we are
paying out(primarily network access fees) on a per state basis. So I
really need to know the average number of contracts in each
state/country(which I break out later). The contract counts are a
VERY small part of the report. The DB2 proc that I hope to replace
with access runs 17 queries pulling data from 9 different DB2 tables.
When all is said and done the final report is about 250 pages. So
what I need to know is how to calculate the average number of
contracts per month over the number of months in the current year that
each particular group has been a client of my company.(Wow thats a
mouth full) One more thing I know that my method is probably not the
best way of accomplishing the task at hand but I am "self taught" so
have had no formal SQL training thus a limited tool box. In college I
was a physics/math major programming primarily with fortran and LaTex.

Thanks
Nov 12 '05 #3

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

Similar topics

38
2267
by: Remco Groot Beumer | last post by:
Hello, I'm trying to decide if the following situation would be workable: Generate an MS Access Front End (which will run localy on client computers), which will link to a DBMS (SQL server or...
13
6056
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
1
2838
by: Matt Alanzo | last post by:
On another newsgroup an Access knowledgable party posted: >You should be able to connect an Access ADP to an existing SQLExpress >database running in SQLS 2000 compatibility mode. The only thing...
1
4149
by: Norman Fritag | last post by:
Hi there I have avoided to use active x controls because I thought they are causing more problems then they are doing any good. I a new application I would want to use the tree and list view...
19
4065
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
11
6551
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
9
10859
by: Ben Dewey | last post by:
Project: ---------------------------- I am creating a HTTPS File Transfer App using ASP.NET and C#. I am utilizing ActiveDirectory and windows security to manage the permissions. Why reinvent...
4
3497
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
0
3021
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
10
6706
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that...
0
7223
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
7321
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
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7489
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
5624
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,...
1
5047
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...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.