Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Count occurrences in sequence with SQL?
Message
 
 
À
23/08/2006 12:07:43
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01147939
Message ID:
01147964
Vues:
11
This message has been marked as a message which has helped to the initial question of the thread.
Try
SELECT COUNT(DISTINCT mydate) FROM mytable mt1 ;
	WHERE myvalue = "A" ;
		AND NOT EXISTS (SELECT * FROM mytable mt2 ;
				WHERE mt2.mydate = mt1.mydate ;
					AND mt2.myvalue <> mt1.myvalue ) 
>I have a table with multiple records per date, and I need to know the number of days in order, for which all occurances equal a given value. I've found a few half answers, but they're not adding up to a whole.
>
>
>8/21   A
>8/21   P
>8/22   A
>8/22   A
>8/23   A
>8/23   A
>
>
>For the above data, I need to compute the number of days (counting backwards) where all results = "A", while not counting the 8/21 "A" - EG: 2. I've got a object.method that will do it, but I'd prefer an SQL solution rather than SCANning the table and calling the method.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform