>I need help with SPT to db2 database file.
>
>Suppose I need the status of a part number 851251-403.
>
>Alpha codes(suffixes) are used to specifiy color. Business logic says that the part in a series with the latest datetime stamp, no matter the color, drives the part number status.
>
>In my status database I have two records 851251-403 and 851251-403A these have a datetime stamp field and the 851251-403A has the latest datetime stamp.
>
>What would be the SPT syntax to find the 851251-403A record while passing the 851251-403 within my where clause?
One way would be to first get the latest timestamp for the possible parts (as a subquery), then get the columns you want in the main query:
SELECT
PrimaryKey,
PartNumber,
TimeStamp,
OtherColumnsIWant
FROM SomeTable
WHERE PartNumber LIKE '851251-403%'
AND TimeStamp IN
( SELECT
MAX( TimeStamp ) AS MaxTimeStamp
FROM SomeTable
WHERE PartNumber LIKE '851251-403%' )
SQL LIKE can use trailing or leading "%" as multi-character wildcards. If you know the suffix is always at most one character long you could use the "_" character which is a single-character wildcard
e.g. LIKE '851251-403_'
A quick Google search on DB2 timestamps implies a timestamp is a datetime, so my guess is MAX() should work with it.
Regards. Al
"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov
Neither a despot, nor a doormat, be
Every app wants to be a database app when it grows up