Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2012
    Posts
    9

    Unanswered: Sum after a certain date in another table

    I need help with a query. I have a table that has a file# and a date and another table that has a list of the same file# and amounts. i need to sum the amounts on second table if there are after the date of the first table.

    For example:
    File# Date
    a1 12/01/2013
    a2 09/05/2013

    Table2
    File# Date Amt
    a1 10/01/2013 25.00
    a1 01/01/2014 185.00
    a1 02/01/2014 185.00
    a2 11/15/2013 214.00
    a2 12/15/2013 265.00

    ResultQuery
    File# Sum
    a1 370.00
    a2 479.00

    Hope that makes sense.

  2. #2
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    495
    Provided Answers: 24
    Select tbl2.[file#],Sum([amt]) as Sums from tbl2 where tbl2.date >tbl1.date and tbl1.file# = tbl2.file#

    (the tbls join on [file#])

  3. #3
    Join Date
    Feb 2012
    Posts
    9
    Thanks Ranman

    Just a minor edit. Needed to add tbl1 in the from portion.

    Code:
    SELECT tbl1.file#, Sum([amt]) as Sums 
    FROM tbl1, tbl2 
    WHERE tbl2.date > tbl1.date and tbl1.file# = tbl2.file#;

Posting Permissions

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