Results 1 to 2 of 2
  1. #1
    Join Date
    May 2004

    Unanswered: Query problem and totals URGENT!

    Hi there folks,

    I have a problem with a query I'm building.

    I want a calculated field to deduct one figure in one field, from a figure in another. But one of the fields needs to be grouped by another field! Its hard to explain, but in one table, I have a stock code. In another table I have orders for that stock item in various records. In another table I have a record for the items currently in stock.

    I need to calculate the total number of items ordered for each stock item (done) and deduct from this the amount of stock items currently in stock. But when I do this, the query deducts the amount in stock from every record in the order table, where this should only be done once.

    I was able to do this earlier by fiddling about, but I just cant seem to get it working again!

    Help would be greatly appreciated!!!

  2. #2
    Join Date
    Feb 2004
    New Zealand
    Provided Answers: 9
    When using the Groupby function use the Expression as well
    this tell the query to do the Groupby first then do the Expression Last
    also make shour the Expression are at the End of the Query
    Groupbys -> Sums ->Expression

    when you group by and sum the new feild is name sumof.....

    therefore the Expression should show the in the forumla GST: SumOftotal*.125

    i would name then other wise you start getting umOfSumOftotal
    hope this help

    See clear as mud

    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts