Results 1 to 5 of 5
  1. #1
    Sunwers is offline Novice
    Windows 8 Access 2013
    Join Date
    Jul 2014
    Posts
    3

    Help with Queries

    I tried to create a table that would take the sum of one field and multiply it by another field but I'm Doing something wrong. Below is my table that I'm working from and the SQL I created for the query.

    OrderLine Table consist of 4 columns; OrderNum, PartNum, NumOrdered, and QuotedPrice.

    Query I need to create is a table that consist of the OrderNum and OrderTotal for each order. The OrderTotal is the SUM of the NumOrdered multiplied by the QuotedPrice.

    Here is my SQL that I come up with
    SELECT OrderLine.OrderNum, SUM(NumOrdered*QuotedPrice) AS OrderTotal
    FROM OrderLine;

    Once I try to run the SQL it says "Your query does not include the specified expression 'OrderNum' as part of an aggregate function."



    What am I doing wrong....

    Oh I'm using Access 2013 too

    Thanks,
    Sunwers

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try

    SELECT OrderLine.OrderNum, SUM(NumOrdered*QuotedPrice) AS OrderTotal
    FROM OrderLine
    GROUP BY OrderNum
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Sunwers is offline Novice
    Windows 8 Access 2013
    Join Date
    Jul 2014
    Posts
    3
    LOL... I have worked on this all night and couldn't seem to get it to work. I was at my wits end trying to figure out what was wrong. Thank you so much, adding the GROUP BY OrderNum worked great! :-) I think I need to go to bed now and get some rest away from Access for a while. That was really simple after thinking about it, I didn't think that would cause it not to run it correctly by not having the GROUP By at the bottom.

    Thanks Again,
    Veronica

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Further to Paul's advice on the Group By, here are a couple of links that may be useful to you.

    SQL samples and explanations Lots of sql info

    Building a database from a description of the business includes Normalization, entities and relationships

    Good luck

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

Similar Threads

  1. Replies: 6
    Last Post: 11-13-2013, 04:17 PM
  2. sub queries
    By waqas in forum Queries
    Replies: 1
    Last Post: 02-12-2012, 07:29 AM
  3. Sub Queries
    By waqas in forum Queries
    Replies: 5
    Last Post: 01-24-2012, 11:48 AM
  4. Need Help with Queries (I think)
    By Cath_from_Canada in forum Access
    Replies: 2
    Last Post: 03-14-2011, 08:34 AM
  5. Need Help with Queries
    By mulefeathers in forum Queries
    Replies: 2
    Last Post: 05-24-2010, 11:37 AM

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