Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SPT Query
Message
De
16/06/2010 01:37:04
 
 
À
15/06/2010 18:02:07
Steven Dyke
Safran Seats USA
Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01469087
Message ID:
01469161
Vues:
39
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform