Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Count occurrences in sequence with SQL?
Message
 
 
To
23/08/2006 12:07:43
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01147939
Message ID:
01147964
Views:
12
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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform