Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Statement & MAX()
Message
 
 
À
04/06/2007 08:50:47
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01230185
Message ID:
01230199
Vues:
16
Try
SELECT * FROM curShopIssue1 c1
	WHERE date = ( SELECT MAX(date) FROM curShopIssue1 WHERE drwno = c1.drwno) 
	INTO CURSOR curMaxRev 
* or
SELECT c1.* FROM curShopIssue1 c1
	JOIN ( SELECT drwno, MAX(date) as MaxDate FROM curShopIssue1 GROUP BY 1) mdt
		ON mdt.drwno = c1.drwno AND mdt.MaxDate = c1.date
	INTO CURSOR curMaxRev 
>I have a table with the following structure:
>
>
>Drwno     Rev       Date    Code
>101        0      05/12/06   A
>101        1      02/01/07   A
>101        1      04/01/07   A
>102        1      05/12/06   A
>102        1      04/01/07   A
>
>
>I would like an sql statement that has both the max rev and max date for each drawing number as follows:
>
>
>Drwno     Rev       Date
>101        1      04/01/07
>101        1      04/01/07
>
>
>I have tried
>
>SELECT a.drwno, MAX(a.rev) AS rev,MAX(a.date) as date FROM curShopIssue1 a 
INTO CURSOR curMaxRev GROUP BY a.drwno
>
>This seems to work for the 'rev' but does not for 'date'. Any suggestions would be greatly appreciated.
>
>Thanks in advance!
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform