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

SUM & Count

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.[Supplier ID]) AS [No of General Contracts], Count(Tbl_Contract_General_Head.[Supplier ID]) AS [No of Maintenance Contracts]

I thought that i might have been able to use the 'Sum' Function in an expression like sum(count(Tbl_Contract_Maintenance.[Supplier ID]))+count(Tbl_Contract_General_Head.[Supplier ID]).....

but this is not working.

is there another way around this?

Thanks
Jan 8 '08 #1
2 1901
JKing
1,206 Expert 1GB
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.[Supplier ID]) AS [No of General Contracts], Count(Tbl_Contract_General_Head.[Supplier ID]) AS [No of Maintenance Contracts]

I thought that i might have been able to use the 'Sum' Function in an expression like sum(count(Tbl_Contract_Maintenance.[Supplier ID]))+count(Tbl_Contract_General_Head.[Supplier ID]).....

but this is not working.

is there another way around this?

Thanks
Hey there,

Have you tried making a separate query for each count and then combining those fields in a new query?
Jan 8 '08 #2
JKing
1,206 Expert 1GB
Here's an example:

qselGeneralContracts: Query of General Contracts
Expand|Select|Wrap|Line Numbers
  1. SELECT Count(Tbl_Contract_General_Head.[Supplier ID]) AS [No of General Contracts]
  2. FROM
  3.  
qselMaintenanceContracts: Query of Maintenance Contracts
Expand|Select|Wrap|Line Numbers
  1. SELECT Count(Tbl_Contract_Maintenance.[Supplier ID]) AS [No of Maintenance Contracts]
  2. FROM Tbl_Contract_Maintenance.[Supplier ID]
  3.  
Total Contracts
Expand|Select|Wrap|Line Numbers
  1. SELECT [No of Maintenance Contracts], [No of General Contracts],  [No of Maintenance Contracts] + [No of General Contracts] As TotalContracts
  2. FROM qselGeneralContracts, qselMaintenanceContracts
  3.  
Jan 8 '08 #3

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

Similar topics

7
by: sathyashrayan | last post by:
Group, Following function will check weather a bit is set in the given variouble x. int bit_count(long x) { int n = 0; /* ** The loop will execute once for each bit of x set,
1
by: John_H | last post by:
Re: ASP.NET 2.0 I would like suggestions or code examples on how to collect a variable length list of input data (item# & item quantity specifically). I thought that I could accomplish this...
0
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
5
by: ducky801 | last post by:
Hi all. When i run the code below i get a 'NullReferenceException was unhandled' error. I am using VB 2005 Express. I'm confused about this because, I have declared my array and i'm trying to...
0
by: BigAl.NZ | last post by:
Hi Guys, I am trying to write/copy some code that uses events with a GPS. Everytime the GPS position updates the event fires. The GPS code is from a SDK Library that I got called GPS Tools...
6
by: rn5a | last post by:
Suppose a SQL Server 2005 stored procedure looks like this: ALTER PROCEDURE SPName @UserID int SELECT COUNT(*) FROM Table1 WHERE UserID = @UserID SELECT COUNT(*) FROM Table1 In the ASPX...
3
by: Nindi73 | last post by:
Hi, I am in need of a deep copy smart pointer (Boost doesn't provide one) which doesnt require the contained types to have a virtual copy constructor. I wrote a smart pointer class that I think...
1
by: almurph | last post by:
Hi everyone, I'm a newbie to vb.net. I have written some code to detect when a user presses the down-arrow, up-arrow and enter button. Essentially the user can arrow down or up through a...
19
by: arnuld | last post by:
this programme runs without any error but it does not do what i want it to do: ------------- PROGRAMME -------------- /* K&R2, section 1.6 Arrays; Exercise 1-13. STATEMENT: Write a program...
3
by: cris1978 | last post by:
Hi, I'm trying to do this query to update the results in a table, it's compiling and running without problems, but it's not updating the table, could you guys help me? Many Thanks! ...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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
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
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...

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.