Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Trick?
Message
De
27/09/2003 12:47:00
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
SQL Trick?
Divers
Thread ID:
00832936
Message ID:
00832936
Vues:
47
Using the script below how can I get the MAX() date
and the second most max date for each category?

That is I want a result (via a SQL Statement) that
will show the following:
category   date        secondmostrecent
A          01/03/2003  01/02/2003
B          02/03/2003  02/02/2003
CREATE CURSOR xx (category c(1), date d)
INSERT INTO xx VALUES("A", {^2001/01/01})
INSERT INTO xx VALUES("A", {^2001/01/02})
INSERT INTO xx VALUES("A", {^2001/01/03})
INSERT INTO xx VALUES("B", {^2001/02/01})
INSERT INTO xx VALUES("B", {^2001/02/02})
INSERT INTO xx VALUES("B", {^2001/02/03})

SELECT category, MAX(date) date FROM xx GROUP BY category
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform