473,402 Members | 2,061 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.

group by + count problem:

Hi,

I would like to count inspections and group them by customer (for those
where the repdate = #1/1/1900#)

Something like:
SELECT customerid, count() AS Inpections
FROM inspection
WHERE repdate = #1/1/1900#
GROUP BY customerid;

this works fine!
But now i would like the customer name instead of the ID
so i have to join in another table called Customer to find the CustomerName
with the right CustomerID
so i thought it would work like:

SELECT i.customerid, c.customername, count(i.repdate) AS Inpections
FROM inspection AS i, customer AS c
WHERE i.repdate = #1/1/1900#
and i.customerid = c.customerid
GROUP BY i.customerid, c.customername;

when i run this querry, the counts are not correct, (much to high) seems
like it also counts the iteration for the joined table or so.
anybody??

thanks a lot!
bjorn
Nov 13 '05 #1
5 2870
Try without Selecting customerid and group by customerid

Madhivanan

Nov 13 '05 #2
sorry, not working,

same result,
the cout is too high

"Madhivanan" <ma************@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Try without Selecting customerid and group by customerid

Madhivanan

Nov 13 '05 #3
Can you post sample data with expected result?

Madhivanan

Nov 13 '05 #4
hi Madhivanan & others,

you can download an Occess sample db from www.SmartColourSensor.com/db1.mdb
(160Kb)
see querry 1 & 2 (and the tables)
they should give the same result, but don't

Reason is that in the customer table, 1 customer has multiple rows because
of branches.

thanks!
bjorn

"Madhivanan" <ma************@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Can you post sample data with expected result?

Madhivanan

Nov 13 '05 #5
"b. hotting" <bh******@REMOVtHISwxs.nl> wrote in
news:d7**********@reader13.wxs.nl:
hi Madhivanan & others,

you can download an Occess sample db from
www.SmartColourSensor.com/db1.mdb (160Kb)
see querry 1 & 2 (and the tables)
they should give the same result, but don't

Reason is that in the customer table, 1 customer has multiple
rows because of branches.

thanks!
bjorn


You can fix this two ways, the right way is to split your
customer table into customers and customerbranches, or you can
replace the table in your query with a new query that does a
SELECT DISTINCT customerID, customername.
If you do it the first way, you now have a customerbranchID to
do even more sophisticated reporting.

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #6

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...
7
by: Darin | last post by:
I have a report that sub-totals on a group, then grand-totals at the report footer. If there's only one group, the sub-total and grand total are redundant, so I only want to show one of them. I...
9
by: Terry E Dow | last post by:
Howdy, I am having trouble with the objectCategory=group member.Count attribute. I get one of three counts, a number between 1-999, no member (does not contain member property), or 0. Using...
12
by: Bill Moran | last post by:
Hey all. I've hit an SQL problem that I'm a bit mystified by. I have two different questions regarding this problem: why? and how do I work around it? The following query: SELECT GCP.id,...
4
by: Igor | last post by:
I have one SELECT statement that needs to return one ntext field from one table and count something from other table, problem is that all fileds that are not in count have to be in group by and...
7
by: Jeff Kish | last post by:
Hi. I have read lots, but obviously not the right stuff. A reference pointer would be fine, or an answer. I in fact got an oracle solution that I am still researching, but was wondering about...
1
by: sammy | last post by:
If you have a select with 2 attributes where you group by one attribute and do a count() for the second attribute, if the count() is 0 then that row is never displayed. How would you instead see...
10
by: Rudolf Bargholz | last post by:
Perhaps some kind soul could help me out with an SQL I have been trying all day to get to work, where one colum is just not summing up the way I want it to. I have the following data GRP_SEQ ...
5
by: Seb | last post by:
I want to count activity in a given month. I'm trying to do so with the linq code below however it reports: Error 1 'a' is inaccessible due to its protection level var ActivityByMonths = from a...
1
by: plaguna | last post by:
How can I Count the number of Customers that a Sales Person had in a City X? The idea is to Group By and Sub Group By , and then Count the rest of the fields. This is the scenario: ………….…..etc ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.