Sum of Two Union Queries

Hello,

I have the following SQL that produces two record totals (as it
should).  But I want to SUM those two values from within the same
query.  Rather than create a second query that SUMs the two values
from the first query:

SELECT Count(*) AS SubCount
FROM [MyTable1]
WHERE (([MyTable1].UNIQUEUSER)="JOHNSMITH")
UNION ALL SELECT Count(*) AS SubCount
FROM [MyTable2]
WHERE (([MyTable2].SWCASSIGNEDUSER)="JOHNSMITH");

The results I get are:

SubCount
--------------
380
2


I've tried "wrapping" that entire SQL code inside of a SELECT SUM, but
upon execution it says, "this operation is not allowed in subqueries".

Any ideas?

Thanks in advance!

0
Hendy88
5/21/2007 8:52:11 PM
access 16762 articles. 2 followers. Follow

0 Replies
827 Views

Similar Articles

[PageSpeed] 15

Reply:

Similar Artilces:

Locking on Update Query
I have a database that keeps track of credit applications. I am trying to setup a 2 forms to pull up existing apps and edit them. The application data table is linked to an SQL Server 2000 table. I have 2 forms, one tied to a macro which allows me to find the app I want to edit using several criteria and sends the details of the app I select to a temp table, then opens the edit form, which is showing only the app I want to edit. This works fine. However, when I make the edits on the edit form and press the save button, the query runs, tells me I am updating 1 row, then gives me the l...

How to perform sum sum sum...
How to perform sumation within that particular item but the item is not unique...means item 1 has its own quantity and same goes to item 2...but in the same table... -- Message posted via http://www.accessmonster.com On Tue, 17 Apr 2007 05:28:12 GMT, "EMILYTAN via AccessMonster.com" <u33296@uwe> wrote: >How to perform sumation within that particular item but the item is not >unique...means item 1 has its own quantity and same goes to item 2...but in >the same table... Group By the item. For a more detailed answer, please post a more detailed question (with a des...

Have two of every customer in database!! HOW DO I CHANGE??
For Some reason when i created a new database for our new location it created two of every customer. Anybody have any thoughts cuz i sure as hell can't figure out how to erase the copied customers. The only solution I can offer is to manually go in and delete a copy of each customer. My question is : Did the copy get the same account number and if so how? -- Elizabeth M. "LEGENDSBOSS" <SNOWJOE6910@HOTMAIL.COM> wrote in message news:2a07501c46612$97715d10$a501280a@phx.gbl... > For Some reason when i created a new database for our new > location it created two of...

Multiple variables to sort and sum, return values<0 with sum refer
Can anyone help me with this one please? I have this table of data. I'd like to be able to write a formula(s) which sums the No according to date and code, but then only returns a sum value (with the code and date in the two adjacent cells) if there is a value greater than 0. Code Ref No Date 1 G/032/05/999 400600 212 19/03/2010 2 G/032/03/001/999 400500 50 19/03/2010 3 G/032/02/001/001 400400 170 19/03/2010 4 G/032/05/999 400600 315 19/03/2010 5 G/032/03/001/999 400500 300 19/03/2010 6 G/032/05/999 400600 202 19/03/2010 7 G/032/03/001/002 40...

Summing up user defined results
Hi all - I'm new to VBA programming in Excel and so any help i'd totally love! I'm currently writing a function. Objective: user can select rows (do not have to be sequential). User clicks on button. UserForm appears with summed results from ONLY rows that he selected. What I have now, well it doesn't work: Sub Button6_Click() Dim i As Integer Dim totalNumbers As Integer Dim aRange As range For Each a In Selection.Areas 'MsgBox "Area " & i & " of the selection contains " & _ ' a.Rows.Count & " rows." &...

sum subform to form
=Sum([Forms]![frmCamPledgeList].[frmCamPledgeListSub].[Amount Pledged]) Form (frmCamPledgeList) with subform frmCamPledgeListSub). Subform has a field named Pledge Amount. I want to put a field on the form that gives me a total of the subform's Amount Pledged. I have tried the above, but I get an #error in the unbound text box. Do you need any more info? Any thoughts on why this does not work? Thanks in advance, Scott -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200912/1 The proper syntax is =Sum([Forms]![frmCa...

Trouble with union qry
Below is a union query which gathers up shipment and returns to give data representing quality (total returned/total shipped). The query works fine without the WHERE statement for all customers. But I want to filter it out for a specific Account Manager's customer's only. I tried the WHERE statement below, but it doesn't work. WHERE (((qryQualityRGA.AcctmgrID)=getmyvariable())); Interesting to me is using that last statement brings up a parameter box asking for the value of qryQualityRGA.AcctmgrID???? SELECT qryQualityRGA.plant, qryQualityRGA.AcctmgrID, qryQualityRGA.Tr...

Calculate sum of a field within the query
I have a query that returns the details for a failure record during a specified time period. Where if I search between 1/1/08 and 1/31/08 the query returns the records of all failure records during that period. The row shows the part number and the total parts failed for that record. I need the query to then sum the total part failures for the previous 12 months. So I would see the following: Record # | part # | parts failed | Origination Date| Total Parts failed past 12 months 44444 | x | 4 | 1/2/08 | 200 44445 | Y |1 ...

how to make this work if sum=5+n2 then sum becomes the value of s.
I want to get or create a formula in excel or access that allows me to keep a running total of my supplies ie... I have 2 pens, remove one and receive 2. answer in the cell becomes 3 pens then if I zero out the received cell the inventory cell still remembers that I have 3 pens not 4 pens (because I received 2 more pens) and visa versa when I zero out the received cell it remembers I have 3 pens not 1 pen(because I removed 1 pen) I believe the method you suggest is flawed. You have no audit trail. If the number on the sheet doesn't match your actual inventory, how will you figure out...

Calculating a percentage from values in two different fields
Hi, I have a query called SalesBudget3 that has fields which include: CustomerName, Type and then all of the months of the year (January, February). The type field is either Actual or Budget. My query will return two records per client. The first would have their actual sales for 2008 and the second would have their budgeted sales. In my report, I have the field names in the page header (Type, January etc) and CustomerName in the CustomerName header. The Details sections has their monthly sales figures. In the CustomerName footer, I want to calculate percent of Actual to Budget pe...

Complex Query Problem
I have a database with a number of fields Program, LTV, Amount, Price, Rate, Fee. Each row has the same Program, a given list of LTV's, Amounts and Prices. I want to retrieve only the lowest Rate and Fee at each give each program, ltv and amount. I used an update table query but it is inconsistant in returning the lowest rate and fee even though the table from which i am selecting is sort correctly. Any help would be greatly appreciated. thanks Try using a Totals query with Group By as the Total criteria in every field but either Rate or Fee and Min in the Totals row of tha...

=SUM Ranges Do Not Update
I have a Excel 2000 spread sheet, with the following macro to insert new row. Sub InsertRow() ' ' Macro1 Macro ' Macro recorded 4/27/2004 ' 'GoTo label, MyString ActiveSheet.Unprotect Application.Goto Reference:="MyCell" ActiveCell.Select ActiveCell.EntireRow.Insert ActiveCell.Offset(-1, 0).Select ActiveCell.EntireRow.Copy ActiveCell.Offset(1, 0).Select ActiveCell.PasteSpecial xlPasteAll Application.CutCopyMode = False ActiveCell.Select ActiveSheet.Protect DrawingObjects:=True, Contents:=True Scenarios:=True End Sub The problem is that in the "Mycell&qu...

Publishing queries into shared queries?
Hi, I have created a new query in Bussiness portal 2.5. it is adding into 'My Queries' folder. And it is available to me only. No other is able to see that Query. I guess I need to move my query into shared Query folder. But I don't how to do it. can anybody kindly help. its very urgent. -prabhakar Prabhakar, The following section in the Business Portal Administrator's Guide explains how to share queries: Sharing queries among users Only the Business Portal administrator can choose which queries to share; individual users cannot share the queries they create. To...

Sum value between dates problem driving me mad!
Good Evening All, I am really struggling here, have tried, nested IF's including AND's but am a bit stumped. I am fairly familiar with Arrays, but cannot seem to combine all. I have a data table (as detailed below). (Hopefully, this should be 'pastable' into Excel - it works for me) I simply wish to calculate the expected totals per month. Any help & assistance with this would be most welcome. Cheers, Mathew Note, earliest Start is 01/04/03 Start Finish Day Rate Apr-2003 May-2003 Jun-2003 Jul-2003 Aug-2003 01/04/2003 23.00 01/04/2003 09/07/2003 23.00 ...

Conditional Sum Wizard
Currently I am setting up a sheet and I am using the conditional sum wizard for formulas. Once a formula is created the sytem won't let me copy or change a formula. If I try to copy (Copy, paste special) a formula to another cell, the formula won't work anymore. If I create a formula with the wizard and afterwards change one of the parameters, the formula does not work anymore. Can anyone give me a hint on how I can solve these issues? Thanks. Please don't multi-post - you have an answer elsewhere, relating to use of CSE. Pete On Jan 6, 9:23=A0am, MarcoKoenders <MarcoKo...

Sum Question
I am using Excel 2000 I have the following very simple formula in column j Sheet1 =SUM(B5*H5) I have this copied all the way down to line 40. It shows 0 in all of the cells all the way down. I would like for there to be a way that the cell would not show anything in it UNLESS there was something that it was calculating. For example. I have entered data in column b and column h through line 10, but it still shows 0 in column J all the way down to line 40. I realize that it is showing these 0's b/c I have placed the formula there, but is there a way that it will still calculate but only ...

setting up an IIS server to relay email to Exchange in DMZ, through two ISA firewalls.
Hello Sorry about the big mail list, but my question involves 3 different expertise, so I am not sure where to post. In a nutshell what I am trying to do is the following. a) Get IIS, in an anonymous access DMZ, to pick email from my ISP through an ISA server 2004 firewall I haven't figured out yet how to get the mail server to pick up email, I could publish the SMTP server on the external firewall, but all email is currently being sent to my ISP and I quite like this because they can take care of a lot of spam filtering, virus etc. problems for me. b) I then want IIS to forward the...

Sum sum sum
Let me describe my problem... I have a form with with item number with is unique and then i put another form (subform) to linked to record the number of item in and out.... This means a item can have many in and out transactions which make the item number not unique.. My problem is I want to calculate the sum of in quantity within the same item. I want the sum to be keep on increasing when the user enter the quantity. Example user key in 2 then new user key 4 and i want the total quantity to be 6... Please help.... No idea of what i am talking? I will explain... -- Message posted via http:/...

Taking sum of a field from sub report
Hi On a sub report I have a field datetot which is the sum of two fields those two fields are in turn coming from two further sub reports of the sub report. How can I take the sum of datetot field to the main report? Thanks Regards See: Bring the total from a subreport onto a main report at: http://allenbrowne.com/casu-18.html -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "John" <John@nospam.infovis.co.uk> wrote in message news:OCWbU...

Access Query
Good Day Situation: I have a query in which I am trying to create to address the following data in my table. The coding is created in two parts Changes completed (qryTask): SELECT [tblWorkload Information Tracker].ProductionAssigned, [tblWorkload Information Tracker].DatatrakNumber, [tblWorkload Information Tracker].DateReceived, [tblWorkload Information Tracker].WorkType, [tblWorkload Information Tracker].WorkCategory, [tblWorkload Information Tracker].EffectiveDate, [tblWorkload Information Tracker].QandALead, [tblWorkload Information Tracker].QAComplete, (IsNull([...

Adding Sum
I made a query report with unique records to display,I don't want repeating item displayed in the report. What should I do to sum the other qty delivered in a single item. Item Qty Date Pork 50 08/01/05 60 08/10/05 20 08/15/05 should be Item Qty Date Pork 130 08/01/05 - 08/15/05 thanks & Godspeed. One way Sub Test() Dim iLastRow As Long Dim i As Long Dim dteMax As Date Dim dteMin As Date Dim...

sum command do not display the result eg:=sum(c5:c8)-total not
sum command do not display the result eg:=sum(c5:c8)-total not display the result in the cell even when sigma is clicked the same What is displayed instead? If you see the formula, then format the cell as General (or anything but text) and reenter that formula. If you see the wrong answer, then maybe you have calculation set to manual. Tools|Option|calculation tab is how you'd change it in xl2003 menus. If that's not it, then maybe your values in those cells (C5:C8) aren't really numbers. Reformat that range as General (not text) and reenter the values. abbbalu wr...

FRX
I have two companies but different functional currencies and common reporting currency. Can I use reporting tree in FRX. (V 6.7) for these two companies. ...

SUM with WHERE
I have one sheet with a bunch of records that look like: Name, Lang, Qty Peter, English, 5 Peter, French, 2 Dave, English, 7 .... On a second sheet I want to create a summary of the records: English, 12 French, 2 So What I am kind of looking for is this: English, =sum of $DRECORDS where Lang=English French, =sum of $DRECORDS where Lang=French Any ideas how to do this in excel? Peter Look in the help index for SUMIF -- Don Guillett Microsoft MVP Excel SalesAid Software dguillett1@austin.rr.com "Peter Carlson" <peter@h_o_w_u_d_o_d_a_t.com> wrote in message news:e1l3%233eXI...

Data entry Query
Hi I am trying to have a query open up (which later I will use as a form) so that I can do data entry, but because I am joining a table it does not allow me to add records (One to many relationship). The PartNumberTests_tbl table contains all tests pertaining to a specific part number. In the TestResults_tbl table I want to be able to add the results of each test that applies to the queried partnumber. I do not need to write anything to the PartNumberTests_tbl table since it is updated by the use of a form (adding or modifying test parameters for a specific part number) Can this be done...