473,406 Members | 2,619 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,406 software developers and data experts.

count() and sum() on multiple tables

I have 3 tables

clients
-cID //pk
-cName

visits
-vID //pk
-cID //client ID
-vDate //format YYYY-MM-DD
-vVisits //int

forms
-fID //pk
-cID //client ID
-fDate //format YYYY-MM-DD
-fMessage

My 3 Tables with Data

clients
//cID - cName
1 - company1
2- company2

visits
//vID - cID - vDate - vVisits
1 - 1 - 2007-06-22 - 50
2 - 1 - 2007-06-23 - 75
3 - 2 - 2007-06-22 - 100
4 - 2 - 2007-06-23 - 125
5 - 2 - 2007-07-01 - 150
6 - 2 - 2007-07-02 - 150

forms
//fID - cID - fDate - fMessage
1 - 1 - 2007-06-22 - "Bob"
2 - 1 - 2007-06-23 - "Ronald"
3 - 2 - 2007-06-22 - "Mike"
4 - 2 - 2007-06-23 - "Stan"

I'm hoping to get the following result
//company name (cName) - Group by Months - Group by Years - SUM of visits by months - COUNT of forms by months
company1 - 6 - 2007 - 125 - 2
company2 - 6 - 2007 - 225 - 2
company2 - 7 - 2007 - 300 - 0


Is it possible in a single query?
Jun 22 '07 #1
0 1769

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Good Man | last post by:
Hi all Well, I didn't want to have to bring this question to someone else to answer, but I am truly flummoxed and could use some help. It all boils down to trying to find the number of jobs...
0
by: Brent | last post by:
In the usual case, this SQL select count(*) from mytable where ... returns an accurate count of the rows you want. But how do I go about counting rows from this SQL (the sum...if statements...
2
by: Scott Cannon | last post by:
I am trying to query 3 tables all related by Clinet_ID. The Clients table, Monthly_Expenses table and Monthly_Income table. Each client can have 0>M instances of expenses, past due expenses, and...
2
by: cefrancke | last post by:
I can't seem to find a straight answer for my specific issue. Any help would be appreciated. I would like to count the various items in a table where the fields have a 'group' relationship. I...
4
by: max | last post by:
I am beginning to learn sql and need some help. I have a table of customers with their addresses. Let's say I want to run a query returning the number of customers whose last name is "Smith" by...
4
by: crane.jake | last post by:
Hi, I'm trying to find the following information from the table found bellow. Year_Sales - # of sales that have occurred this year Year_Income - SUM(amount) Month_Sales - # of sales that have...
1
by: zafm86 | last post by:
Hi everyone! I'm sure my problem is pretty easy to solve but I've been working on it for a long and my my brain is not working correctly anymore. I'm working with an AS400 and I mhave to do an...
1
by: nospam | last post by:
I have a report to count some statistics of case data. I can't figure out how to make Access group and sum/count information to give me a nice statistics report. Basically the database has case...
2
by: jadeverell | last post by:
Hi, I am trying to perform a calculation that adds together two 'Counts' (on seperate tables) to give a total value. The code for the two counts is: Count(Tbl_Contract_Maintenance.) AS ,...
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
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
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
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...
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.