+ Reply to Thread
Results 1 to 3 of 3

Thread: Select 0 record if exists, else select max value

  1. #1

    Default Select 0 record if exists, else select max value

    Have you tried using OPNQRYF with a combination "IF" using the %MAX function? Dave

  2. #2
    Guest.Visitor Guest

    Default Select 0 record if exists, else select max value

    I have a file that "expires" records by placing a date in a field. The "current" record has a date of 0, but on some occassions all records may be expired so the current record is the one with the greatest date. I have been racking my brain for a Select statement that will select the 0 record if it exists, otherwise select the record with the greatest date value if a 0 record does not exist. Any suggestions would be greatly apprceciated.

  3. Default Select 0 record if exists, else select max value

    I'm tired this morning so I'm not up to being careful about the SQL syntax but something like the following should work Select * From T where (Case when DateField = 0 Then "9999-01-01" else DateField End) = (Select Max(Case when DateField = 0 Then "9999-01-01" else DateField End) From T)

+ Reply to Thread

Similar Threads

  1. Select into
    By Guest.Visitor in forum SQL
    Replies: 1
    Last Post: 05-18-2005, 10:48 AM
  2. Need SQL select help please...
    By DougCMH in forum SQL
    Replies: 3
    Last Post: 10-08-2003, 08:48 AM
  3. From SELECT to an
    By Guest.Visitor in forum Programming
    Replies: 1
    Last Post: 03-03-2001, 06:50 AM
  4. Record Duplication in SELECT Query
    By Guest.Visitor in forum Programming
    Replies: 6
    Last Post: 05-28-1999, 04:55 AM
  5. SQL Select
    By Guest.Visitor in forum Application Software
    Replies: 0
    Last Post: 01-01-1995, 02:00 AM

Posting Permissions

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