Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select last 5 days in between
Message
 
 
À
21/08/2004 11:11:47
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00935195
Message ID:
00935225
Vues:
21
Paul,

Try
SELECT TOP 5 dDate ;
  FROM mytable ;
  GROUP BY 1 ;
  ORDER BY 1 DESC ;
  INTO CURSOR crsDates

SELECT * ;
	FROM mytable ;
	WHERE dDate IN ( ;
		SELECT dDate FROM crsDates)
In VFP9 it could be done in one query
SELECT * ;
	FROM mytable ;
	WHERE dDate IN ( ;
		SELECT TOP 5 dDate ;
		  FROM mytable ;
		  GROUP BY 1 ;
		  ORDER BY 1 DESC )
>
>MyTable is:
>
>cSname dDate
>
>aaaaaa 08/15/2004
>bbbbbb 08/15/2004
>
>cccccc 08/17/2004
>dddddd 08/17/2004
>
>eeeeee 08/19/2004
>
>ffffff 08/14/2004
>gggggg 08/14/2004
>
>hhhhhh 08/20/2004
>iiiiii 08/21/2004
>
>jjjjjj 08/03/2004
>kkkkkk 08/03/2004
>
>I would like to put the last 5 days into Mycursorresult to have
>
>aaaaaa 08/15/2004 ( day number 5 to pick )
>bbbbbb 08/15/2004
>
>cccccc 08/17/2004
>dddddd 08/17/2004
>
>eeeeee 08/19/2004
>
>hhhhhh 08/20/2004
>iiiiii 08/21/2004 ( day number 1 to pick )
>
>I try this but never worked because dDate can be skipped 1 or more days in
>between like the above sample.
>
>local ldStart,ldStop,lcQuery
>
>ldStart = first day to pick {08/21/2004}
>ldStop = 5th day to pick {08/15/2004}
>
>** and it is not the last 5 days in the row from 08/21/2004 to 08/17/2004
>
>lcQuery=Select * from mytable where dDate between ?ldStart and ?ldStop
>
>into mycursorresult
>
>Please fix my query or advise me how to do it
>TIA
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform