Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2010
    Posts
    2

    Unanswered: Query question How filter multiple sell-codes by last date created

    I have multiple items with different dates:
    Sell Code ActCode ActDate Sells
    5515 Buy 15/05/2008 5
    5515 Revised 16/05/2008 4
    5516 Buy 17/05/2008 10
    5516 Revised 18/05/2008 12
    5516 Cancelled 19/05/2008 12

    I only want to get the bought one if there is no revised or cancelled sells,
    And only the revised if it is not cancelled, so basically filtered on last transaction date

    What I would like to get is the following result
    Sell Code ActCode ActDate Sells
    5515 Revised 16/05/2008 4

    (the 5516 should not come up as it is cancelled, nor the others)

    How should the query look like,

    Thanks
    Last edited by YannickSites; 10-27-10 at 04:21.

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Code:
    ... 
    where code = 'Buy'
      and sell not in (select sell from your_table
                       where code = 'Cancelled'
    				  )

Posting Permissions

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