Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Group by vfp 8
Message
From
05/03/2004 12:28:54
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00883423
Message ID:
00883572
Views:
6
This message has been marked as the solution to the initial question of the thread.
yes, but if exists two or more maximum ?
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)

INSERT INTO Sales VALUES (1, {^2004/01/16}, 200)
INSERT INTO Sales VALUES (3, {^2004/01/02}, 100)

* all
SELECT Customer, Purchase, Amount ;
FROM Sales WHERE Amount = (SELECT MAX(Amount) FROM Sales S WHERE Customer = Sales.Customer)

* last
SELECT Customer, MAX(Purchase), Amount ;
FROM Sales WHERE Amount = (SELECT MAX(Amount) FROM Sales S WHERE Customer = Sales.Customer);
GROUP BY Customer, Amount
Fabio
Previous
Reply
Map
View

Click here to load this message in the networking platform