Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2002
    Posts
    7

    Unanswered: Last N transactions

    This must be a common requirement, but I can't find an elegant solution...

    I have a master file and a transaction file. I want to report on the last 5 transactions for each master file entry.

    Please embarass me by poining out how easy this is.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    try

    Code:
    select trans_masterid, trans_date
      from transactions XXX
     where trans_date in
           ( select top 5
                    trans_date
               from transactions
              where trans_masterid = XXX.trans_masterid
           order by trans_date desc )
    order by trans_masterid, trans_date desc
    rudy
    http://rudy.ca/

  3. #3
    Join Date
    Aug 2002
    Posts
    7
    That looks good. Thanks.

  4. #4
    Join Date
    Aug 2002
    Posts
    7
    Works like a charm, Rudy.

    Thanks. I would never have come up with that myself.

Posting Permissions

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