Results 1 to 2 of 2
  1. #1
    becka11 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Posts
    13

    Calculated field on results in the same query

    Hi,



    I am wondering if it is possible to make a calculated field on a field in the same query. For example, say I have a products table with products and prices. Then I make a select query to pull all products with a price of zero. In that same query can I also count how many products there are with the price of zero. Or do I NEED to make a second query on top of the first to count all of the products listed in query 1.

    This is a simple application, but there are many instances where I have wanted to do this, but always end up having to do two separate queries.

    Any help is GREATLY appreciated!!

    Thank you

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Options:

    1. the two query method you already know

    2. a GROUP BY (Totals) aggregate query, try:
    SELECT Product, Price, Count(ID) As CountOfID FROM tablename GROUP BY Product HAVING Price=0;

    3. domain aggregate function

    4. a report using grouping & sorting features with aggregate calcs in group footer
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 3
    Last Post: 02-13-2013, 10:15 AM
  2. Replies: 1
    Last Post: 06-26-2012, 05:02 PM
  3. Replies: 3
    Last Post: 06-26-2012, 02:54 PM
  4. Replies: 3
    Last Post: 03-03-2012, 10:39 PM
  5. union query with a calculated field
    By grad2009 in forum Queries
    Replies: 9
    Last Post: 03-31-2010, 04:50 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