Results 1 to 2 of 2

Thread: SQL help (SQL)

  1. #1
    2 Star Lounger
    Join Date
    Jun 2003
    Location
    New Jersey
    Posts
    103
    Thanks
    6
    Thanked 0 Times in 0 Posts

    SQL help (SQL)

    Please find attached an example of 2 tables. One table lists all the positions in the (big) table from the history. The second table are the employees and the assigned position. What I am looking for is to join the two tables but only display the positions that are not attached to a person. I also must have the top most record for the position since the (big) table can have multiple records for one position number. I have the sql statement to get the top most record but how do i join the two tables and return the records that don't exist in the personposition table.

    This is what I have so far:

    select PositionCode, PositionStartDate, PositionEndDate
    from vPositionHist pbh
    Where pbh.PositionStartDate= (select max(PositionStartDate) From vPositionHist pbh1
    where pbh.PositionCode=pbh1.PositionCode and pbh1.PositionStartDate<getdate())
    order by positioncode

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: SQL help (SQL)

    I would create the query using the Find Unmatched Query Wizard, then look at the SQL of the query generated by the wizard.

Posting Permissions

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