Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    London
    Posts
    46

    Unanswered: Selecting last Date/Record only

    Hi all,

    Done some searching but can't really find what I'm after. This should be quite a simple one but as it's the end of the week by brain isn't working hehe.

    Right I have a monsterous database that contains career history, wage history and so on. The module of data for career history contains info for an individual this like

    employee ID Postition Title from to
    123456 Tea boy 1/1/01 1/2/03
    123456 Managing Director 1/2/03 18/06/04

    What I want to do is select the guys current job (which will be managing director) out of this long list. I'd rather NOT do it out of "to" as the infomation has come from SAP and is end of time dates and so on.

    So my question is..how do I take only the last date out of from / greatest value in a query (rather do it in that). I don't want to put in "1/2/03" in ym criteria as theres 1000's of records in here

    thanks in advance!

  2. #2
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    Select *
    from tableA ta
    where date = (select max(date) from tableA)

    Should you wish to further restrict the results, then

    where date = (select max(date) from tableA where column = ta.column)
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

  3. #3
    Join Date
    Feb 2004
    Location
    London
    Posts
    46
    thanks very much matey, that works great
    *high 5*

Posting Permissions

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