SQL Help please

Discussion in 'OT Technology' started by DiabSoule!, Sep 10, 2004.

  1. DiabSoule!

    DiabSoule! ooh, plum been runnin', buck a doz. ooh, smoke ba

    Joined:
    Mar 15, 2000
    Messages:
    5,000
    Likes Received:
    0
    Location:
    Toronto, Canada
    Lets say you have the following records, how would you go about only selecting the record with the highest date of each bunch, ie. the highest of xxxx, yyyy, the highest of xxxx, tttt. so in this case, i would only want xxxx, yyyy, 03/05/99, xxxx, tttt, 03/04/99, and since there's only one xxxx, bbbb then xxxx, bbbb, 05/03/99

    if it makes it any easier, the highest date record will always be the last for every field1 and field2.

    xxxx, yyyy, 01/01/99
    xxxx, yyyy, 02/02/99
    xxxx, yyyy, 03/05/99
    xxxx, tttt, 02/04/98
    xxxx, tttt, 03/04/99
    xxxx, bbbb, 05/03/99
     
  2. bleak

    bleak Guest

    SELECT xxx, yyy FROM table_name ORDER BY date DESC LIMIT 1;
     
  3. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    or if it's mssql:
    SELECT TOP 1 xxx, yyy FROM table_name ORDER BY date;
     
  4. DiabSoule!

    DiabSoule! ooh, plum been runnin', buck a doz. ooh, smoke ba

    Joined:
    Mar 15, 2000
    Messages:
    5,000
    Likes Received:
    0
    Location:
    Toronto, Canada
    damn Pervasive SQL, the syntax for limiting must be different (ie top 1 or LIMIT 1).

    thanks for your help though.
     

Share This Page