Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select records with Maximum date group by address
Message
De
02/10/2002 17:22:42
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00705983
Message ID:
00707110
Vues:
21
I attempted some of the same queries mentioned in this thread against my own data. A lot of them didn't work. In the process I noticed that my own was wrong (what else is new :-))

What did work:

SELECT a.customer_name, b.*
FROM customer a, address b
where a.customer_id = b.customer_id and
STR(b.customer_id, 19) + " " + TRANSFORM(b.effective_date) IN
(SELECT MAX(STR(c.customer_id, 19) + " " + TRANSFORM(c.effective_date))
FROM address c
GROUP BY c.customer_id)

In order to test the results, choose a customer that you know has two or more address records. If this works, you should be able to use MAX to see the most recent address and MIN to see the oldest address. I hope I didn't miss something in your posting (my usual mistakes.)

I use STR() instead of TRANSFORM to ensure the length of the result. The space is used just to view the results.
Gordon de Rouyan
DC&G Consulting
Edmonton, Alberta
Email: derouyag@shaw.ca
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform