473,804 Members | 3,790 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Summing Queries?

I have about 40 different defects I'm tracking. I'd like to have all of
these defects totaled individually, both by month and by year. I'd like to
show these results in a report. I know I could create 40 queries (one for
each defect) with just the two fields, count and defect, and sum the count
field but that sounds like a lot of work.
Is there a way I can do this much simpler and quicker?
My database has two fields, one is called "count" (where a number is entered
to count the number of defects). The second field is called "Defect
Description" (where the defect type is entered).
Thanks,
Don..........
Nov 13 '05 #1
13 1655
Don Sealer wrote:
I have about 40 different defects I'm tracking. I'd like to have all of
these defects totaled individually, both by month and by year. I'd like to
show these results in a report. I know I could create 40 queries (one for
each defect) with just the two fields, count and defect, and sum the count
field but that sounds like a lot of work.
Is there a way I can do this much simpler and quicker?
My database has two fields, one is called "count" (where a number is entered
to count the number of defects). The second field is called "Defect
Description" (where the defect type is entered).


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You mean your table has 2 columns (aka fields). A database has tables;
tables have columns.

Something like this:

SELECT DefectDescripti on, SUM(DefectCount ) AS Defects
FROM table_name
GROUP BY DefectDescripti on

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQzcbF4echKq OuFEgEQIeawCfcT J5SqfDRWUjvcIpc BGxEoEjvDMAoNch
N4RrRKNg5lUcDom gY3aFr7AY
=L7Nm
-----END PGP SIGNATURE-----
Nov 13 '05 #2
I understand about Field vs column. With that in mind I need some
additional help.
Actually my database has many columns. Two of them are Defect Count &
Defect Description.
How do I write this query? I've tried several different ways but I keep
getting errors, syntax and such. Here's what I've got but it's not working.
Also how could I sort this by month and then by year?
Thanks again for your help and guidance,
Don...........

SELECT Defect Description, sum(Defect Count) AS defects
FROM [Data Collection Table];
Group by Defect Description
"MGFoster" <me@privacy.com > wrote in message
news:vW******** ********@newsre ad2.news.pas.ea rthlink.net...
Don Sealer wrote:
I have about 40 different defects I'm tracking. I'd like to have all of
these defects totaled individually, both by month and by year. I'd like to show these results in a report. I know I could create 40 queries (one for each defect) with just the two fields, count and defect, and sum the count field but that sounds like a lot of work.
Is there a way I can do this much simpler and quicker?
My database has two fields, one is called "count" (where a number is entered to count the number of defects). The second field is called "Defect
Description" (where the defect type is entered).


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You mean your table has 2 columns (aka fields). A database has tables;
tables have columns.

Something like this:

SELECT DefectDescripti on, SUM(DefectCount ) AS Defects
FROM table_name
GROUP BY DefectDescripti on

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQzcbF4echKq OuFEgEQIeawCfcT J5SqfDRWUjvcIpc BGxEoEjvDMAoNch
N4RrRKNg5lUcDom gY3aFr7AY
=L7Nm
-----END PGP SIGNATURE-----

Nov 13 '05 #3
I got it. I didn't type it correctly. It works very well thank you
In order to sort these by month and year would it be best to create a query
by month and another query by year? Would it be possible to show both of
these in a single report?
Thanks again for your help,
Don............ ..

"Don Sealer" <vz******@veriz on.net> wrote in message
news:yxGZe.1957 $%L4.850@trndny 02...
I understand about Field vs column. With that in mind I need some
additional help.
Actually my database has many columns. Two of them are Defect Count &
Defect Description.
How do I write this query? I've tried several different ways but I keep
getting errors, syntax and such. Here's what I've got but it's not working. Also how could I sort this by month and then by year?
Thanks again for your help and guidance,
Don...........

SELECT Defect Description, sum(Defect Count) AS defects
FROM [Data Collection Table];
Group by Defect Description
"MGFoster" <me@privacy.com > wrote in message
news:vW******** ********@newsre ad2.news.pas.ea rthlink.net...
Don Sealer wrote:
I have about 40 different defects I'm tracking. I'd like to have all of these defects totaled individually, both by month and by year. I'd
like
to show these results in a report. I know I could create 40 queries (one for each defect) with just the two fields, count and defect, and sum the count field but that sounds like a lot of work.
Is there a way I can do this much simpler and quicker?
My database has two fields, one is called "count" (where a number is entered to count the number of defects). The second field is called "Defect
Description" (where the defect type is entered).


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You mean your table has 2 columns (aka fields). A database has tables;
tables have columns.

Something like this:

SELECT DefectDescripti on, SUM(DefectCount ) AS Defects
FROM table_name
GROUP BY DefectDescripti on

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQzcbF4echKq OuFEgEQIeawCfcT J5SqfDRWUjvcIpc BGxEoEjvDMAoNch
N4RrRKNg5lUcDom gY3aFr7AY
=L7Nm
-----END PGP SIGNATURE-----


Nov 13 '05 #4
Don Sealer wrote:
I got it. I didn't type it correctly. It works very well thank you
In order to sort these by month and year would it be best to create a query
by month and another query by year? Would it be possible to show both of
these in a single report?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

If you have the date value in the same table just add the date to the
query:

SELECT date_column, [Defect Description], SUM([Defect Count]) AS Defects
FROM table_name
GROUP BY date_column, [Defect Description]

The JET engine (the Access database engine) will sort the columns in the
GROUP BY clause in ascending order. If you want a different order add
the ORDER BY clause:

ORDER BY date_column DESC, [Defect Description]

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQzdI0oechKq OuFEgEQKj+QCcCt x4oOLajP7GpiWb9 vxmD26gE9MAoO04
6OzSSR1XyQQH1uw Fce+wkbDw
=WXKq
-----END PGP SIGNATURE-----
Nov 13 '05 #5
Thanks for your reply. I'm kind of stuck. The first reply you gave me
worked well except it didn't separate the data by month and year. The last
reply gave me results but it listed all records, it didn't group the results
by defect description. It's probably something I'm not doing correctly.
The last suggesting gave me every record with dates. I was really hoping
for a finished result that would list the defects by the current month,
summed, and grouped by the defect description. I would also like to see the
same thing except it would be by the year, summed, and grouped by the defect
description.
I've played with the SQL several different ways to try and get these results
but haven't been able to.
Can you suggest what I might be doing wrong or another approach?
Thanks again,
Don...........
"MGFoster" <me@privacy.com > wrote in message
news:sN******** ********@newsre ad2.news.pas.ea rthlink.net...
Don Sealer wrote:
I got it. I didn't type it correctly. It works very well thank you
In order to sort these by month and year would it be best to create a query by month and another query by year? Would it be possible to show both of these in a single report?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

If you have the date value in the same table just add the date to the
query:

SELECT date_column, [Defect Description], SUM([Defect Count]) AS Defects
FROM table_name
GROUP BY date_column, [Defect Description]

The JET engine (the Access database engine) will sort the columns in the
GROUP BY clause in ascending order. If you want a different order add
the ORDER BY clause:

ORDER BY date_column DESC, [Defect Description]

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQzdI0oechKq OuFEgEQKj+QCcCt x4oOLajP7GpiWb9 vxmD26gE9MAoO04
6OzSSR1XyQQH1uw Fce+wkbDw
=WXKq
-----END PGP SIGNATURE-----

Nov 13 '05 #6
writing 40 queries isn't that big of a deal.. but you should be able to
reuse some of them

Nov 13 '05 #7
Don:

You should take a look at a crosstab query. I think that will give you
what you're looking for. Use the wizard, it should walk you right
through creating it. It will need to be based on a query that shows
every record without grouping to work properly. So first have a query
like this:

SELECT date_column, [Defect Description], [Defect Count]
FROM table_name

Then use that query for the source of the crosstab query. In the
wizard you'll be able to pick how to group the dates, too. You're
going to want to have the Defect Description as a row heading, the Date
Column as a column heading, pick the desired date grouping, and
Sum([Defect Count]) as the calculated number to display in each
intersection. That should do it!!

Good luck,
Jana

Nov 13 '05 #8
Thanks Jana,
I've never used a crosstab query before. Actually I've never really used
the SQL query function before. I'm learning to do both right now.
You're idea is perfect with a couple of exceptions. Actually I do get the
results I wanted. However I was hoping to get a little more. For instance.
The query does give me each month and a total of all months, so that is
great. If it's possible in my report I'd like to compare the current month
against the rest of the months. Is that possible?
I'd also like to display the names of the defects in the report. Right now
it doesn't do that, can it be done.
Thanks for your help, this cross tab query presents some great options.
I'll just need to understand how it all works so I can use it in for future
apps.
Thanks again,
Don............ .....

"Jana" <Ba********@gma il.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Don:

You should take a look at a crosstab query. I think that will give you
what you're looking for. Use the wizard, it should walk you right
through creating it. It will need to be based on a query that shows
every record without grouping to work properly. So first have a query
like this:

SELECT date_column, [Defect Description], [Defect Count]
FROM table_name

Then use that query for the source of the crosstab query. In the
wizard you'll be able to pick how to group the dates, too. You're
going to want to have the Defect Description as a row heading, the Date
Column as a column heading, pick the desired date grouping, and
Sum([Defect Count]) as the calculated number to display in each
intersection. That should do it!!

Good luck,
Jana

Nov 13 '05 #9
Actually I'm getting closer. I've figured out the description problem so
now I'm left with only the problem of how do I get it to report only the
current month and all the other months as year. In the report I choose the
month of Aug (just for practice) and of course the query shows a total for
all months (year). This is great but how can I get just the current month?
If I add some verbiage such as:
WHERE (((Format([Date],"mm/yyyy"))=Format( Date(),"mm/yyyy")));

Would that work?? I'm probably going to try and put it in but I've got a
feeling it will do something negative to what you've already suggested. I
suppose I'd be willing to go into the report each month and change it to
accommodate whatever month we're in.
Not sure verbiage is the correct term but someone will probably tell me what
is correct.
Thanks so much for your help,

Don............ .
"Don Sealer" <vz******@veriz on.net> wrote in message
news:24_Ze.1989 5$Fh4.2744@trnd ny03...
Thanks Jana,
I've never used a crosstab query before. Actually I've never really used
the SQL query function before. I'm learning to do both right now.
You're idea is perfect with a couple of exceptions. Actually I do get the
results I wanted. However I was hoping to get a little more. For instance. The query does give me each month and a total of all months, so that is
great. If it's possible in my report I'd like to compare the current month against the rest of the months. Is that possible?
I'd also like to display the names of the defects in the report. Right now it doesn't do that, can it be done.
Thanks for your help, this cross tab query presents some great options.
I'll just need to understand how it all works so I can use it in for future apps.
Thanks again,
Don............ .....

"Jana" <Ba********@gma il.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Don:

You should take a look at a crosstab query. I think that will give you
what you're looking for. Use the wizard, it should walk you right
through creating it. It will need to be based on a query that shows
every record without grouping to work properly. So first have a query
like this:

SELECT date_column, [Defect Description], [Defect Count]
FROM table_name

Then use that query for the source of the crosstab query. In the
wizard you'll be able to pick how to group the dates, too. You're
going to want to have the Defect Description as a row heading, the Date
Column as a column heading, pick the desired date grouping, and
Sum([Defect Count]) as the calculated number to display in each
intersection. That should do it!!

Good luck,
Jana


Nov 13 '05 #10

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

Similar topics

9
2578
by: Yaroslav Bulatov | last post by:
I made an array of 10 million floats timed how long it takes to sum the elements, here's what I got (millis): gcc -O2: 21 Python with numarray: 104 Python with Numeric: 302 java: 325 gcc: 348 Python with Psyco: 1317 Pure Python using sum: 2312
0
1447
by: Marco Alting | last post by:
Hi I have three levels of cost items, like the following: TOP_LEVEL SECOND_LEVEL cost_item1 cost_item2 etc... TOP_LEVEL2
3
2002
by: Richard Coutts | last post by:
I have two queries each of which having a column that I want to sum, and then add the two sums together. When I sum one query or the other, I get reasonable numbers. But when I try to add the two sums together I'm getting a ridiculously high number. Below is my SQL line that is trying to add together the colomns of qryDetlPALIncome and qryDetlPALIncomeNoInvoice. SELECT ...
1
1229
by: Justin | last post by:
We currently have a solution to this coded in VBA in Excel, but the 255 column limitation, general slowness, and instability of Excel are rapidly becoming problems. Access has been suggested as a good user-friendly solution. The situation is this: every day we get an Excel list (or comma delimited, or XML, however we specify) of payments for different products on different days, going out to 2035 or so. For example, assume today is...
0
1923
by: flamingo | last post by:
I have a query that works just fine, but because I need to use it in Business Objects and I have to use a prompt for the date, I need the initial query for the count as a correlated subquery in the from clause, not in the select statement. I've figured out what I'd like to have, however, I only get one row back (and it is correct!) I need to get the results that the initial query gives me, which is about 10 rows. Is there any way I can do...
0
1384
by: King | last post by:
Hi I have 2 queries where I calculated time elapsed. In the first I calculated time spent by a employee in group meetings and in the second query, I calculated time spent by an employee in personal meetings with the clients. I wish to join the two queries to sum up the total time. I have the following fields Fields for Group hours query
4
2538
by: dancole42 | last post by:
So I have an invoicing database based on two main forms: Orders and OrderLines. Orders has fields like: OrderID BillingMethod OrderDate CreditCard CCExp OrdSubTotal ShippingCharge
7
15007
by: lethek39 | last post by:
Hey I have been trying to figure out how to sum rows and columns in a matrix square. I also have been trying to get the program to list the numbers of the diagonal in the matrix. So far this is the code I have (I am using Python): def generate (rows, cols): # This just prints the coordinates and the number that goes in it, It also prints the matrix in a square import random m = {} for r in range(rows): for c in...
1
1678
by: MobiusDick | last post by:
Hi Everyone, I'm having a slight problem summing (almost) an entire recordset: I have an application that when given a table of customers and their estimated annual electricity consumption will generate a matrix of coefficients that gives a typical consumption profile (i.e. how much electricity they are using in any half hourly period). The matrix is a table "tblProfileForPeriod" with the fields as follows: ...
0
9705
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10323
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10311
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7613
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5516
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.