Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Trick?
Message
From
27/09/2003 12:47:00
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
SQL Trick?
Miscellaneous
Thread ID:
00832936
Message ID:
00832936
Views:
45
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
Next
Reply
Map
View

Click here to load this message in the networking platform