Selecting The Earliest or Latest Date From An SQL Table

In Sage 100, I am attempting to select the earliest and latest dates from the completed date column on the work order scheduling tab.  I need to do this via an SQL table.  Currently, I am using the following calculation: [SELECT srvsch.findte FROM srvsch WHERE srvsch.recnum = {srvinv.recnum} AND srvsch.linnum = 1] to select the date associated with the top line of the table.  Obviously, it is not always accurate to assume that this line is chronologically first.  Additionally, I have no idea how to determine which line is chronologically last.  Any help would be greatly appreciated.

Parents Reply
  • 0 in reply to Kevin M

    You are correct.  My SQL query is nested inside an if statement.  I didn't mention that in my original post.  Is that an issue?  The revised SQL query that is working improperly is: [SELECT min(srvsch.findte) FROM srvsch WHERE srvsch.recnum = {srvinv.recnum}].  The if statement seems to be working properly.  It only fails in the condition that it calls for the SQL statement.

Children