Results 1 to 4 of 4
  1. #1
    shekar_genius is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    2

    Sum of Two Feilds of Two Queries in Seperate Query

    I am trying to sum two Feilds each from One Seperate Query, but it is not coming.

    1st Query : I have summed the Collection Details:

    TotalColl,TotalCr,TotalEx,TotalGA,TotalAd,TotalWHT , Against Each Invoice No & CustomerID

    2nd Query : Total of Invoice Amt, TotalOPNWHt, TotalADV,Against Invoice No & CustomerID



    IN the 3rd Query I need All the Feilds : Against Invoice No : I.e

    CustomerID, Invoice No : TotalColl,TotalCr,TotalEx,TotalGA,TotalAd,TotalWHT ,Total of Invoice Amt, TotalOPNWHt, TotalADV [But I needed to Add :TotalWHT+TotalOPNWHt] =Twht


    Kindly Assist.

    Thanks,

    Shekar

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Try this:
    Code:
    Select [1st Query].*,[2nd Query].*, Sum([1st Query].[TotalWHT]+[2nd Query].[TotalOPNWHt]) As Twht
    From [1st Query] Inner Join [2nd Query] on [1st Query].[invoice no] = [2nd query].[invoice no];

  3. #3
    shekar_genius is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    2

    Post Sum of Two Feilds of Two Queries in Seperate Query

    Quote Originally Posted by alansidman View Post
    Try this:
    Code:
    Select [1st Query].*,[2nd Query].*, Sum([1st Query].[TotalWHT]+[2nd Query].[TotalOPNWHt]) As Twht
    From [1st Query] Inner Join [2nd Query] on [1st Query].[invoice no] = [2nd query].[invoice no];
    HI,

    There seems some problem in it either due to some missing information. I just read the error:-You Tried to Execute a query that does not Include the Specified Expression CustomerID as a part of Aggregate Function.

    I Follow through the Queries Again
    1st Query named : SumCollected
    Fields in it:- CustomerID, InvoiceNo,TotalColl,TotalWht,TotalCr,TotalEx,Total GA

    2nd Query Named : TotalInvoice
    FeildsInit:- CustomerID,SalesmanID,Salesman,InvoiceNo,InvAmt,Op nWht,Adv

    The Code sent by you was adjusted in this fashion
    Select [SumCollected].*,[TotalInvoice].*, Sum([SumCollected].[TotalWHT]+[TotalInvoice].[OPNWHt]) As Twht
    From [SumCollected] Inner Join [TotalInvoice] on [SumCollected].[invoiceno] = [TotalInvoice].[invoiceno];

    I need the final query as : Combination of Both

    CustomerID from TotalInvoice, InvoiceNo from TotalInvoice, InvAmt,TotalColl,TotalCr,TotalEx,TotalGA, Twht:Sum([SumCollected].[TotalWHT]+[TotalInvoice].[OPNWHt]),Adv

    Thanks

    Shekar

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Shekar;
    Try this:
    Code:
    Select [SumCollected].*,[TotalInvoice].*, ([SumCollected].[TotalWHT]+[TotalInvoice].[OPNWHt]) As Twht
    From [SumCollected] Inner Join [TotalInvoice] on [SumCollected].[invoiceno] = [TotalInvoice].[invoiceno];
    


    Remove the term sum from the Twht field as that creates an aggregate query which is what caused the error message.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 12
    Last Post: 12-14-2012, 06:25 PM
  2. Replies: 7
    Last Post: 03-30-2012, 09:09 AM
  3. Sum of entries from seperate tables/queries
    By krutoigoga in forum Queries
    Replies: 4
    Last Post: 07-07-2011, 11:54 AM
  4. Count date entries from seperate tables/queries
    By krutoigoga in forum Queries
    Replies: 3
    Last Post: 06-30-2011, 12:48 PM
  5. Replies: 3
    Last Post: 05-21-2010, 03:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums