Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Group by vfp 8
Message
De
05/03/2004 11:44:13
Cindy Winegarden
Duke University Medical Center
Durham, Caroline du Nord, États-Unis
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00883423
Message ID:
00883539
Vues:
8
This message has been marked as a message which has helped to the initial question of the thread.
CREATE CURSOR Sales (Customer I, Purchase D, Amount Y)
INSERT INTO Sales VALUES (1, {^2004/01/01}, 150)
INSERT INTO Sales VALUES (1, {^2004/01/02}, 200)
INSERT INTO Sales VALUES (1, {^2004/01/15}, 100)
INSERT INTO Sales VALUES (2, {^2004/02/05}, 50)
INSERT INTO Sales VALUES (3, {^2004/02/01}, 180)
INSERT INTO Sales VALUES (3, {^2004/01/01}, 100)

*!*	I need a select sql that returns ONE record per customer, 
*!*	with the max amount for each customer, and the dato of purchase of this max amount.

*!*	1 2004/01/02 200
*!*	2 2004/02/05 50
*!*	3 2004/02/01 180

SELECT ;
	Customer, ;
	Purchase, ;
	Amount ;
FROM ;
	Sales ;
WHERE ;
	STR(Amount, 10) + DTOS(Purchase) IN ;
	(SELECT MAX(STR(Amount, 10) + DTOS(Purchase)) ;
	FROM Sales AS Sales1 WHERE Sales1.Customer = Sales.Customer)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform