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:
01147962
Views:
18
This message has been marked as a message which has helped to the initial question of the thread.
Chris,

How 'bout something like this:
SELECT date_fld, COUNT(*) AS rows
	FROM Table_Name
	GROUP BY date_fld
	HAVING date_fld NOT IN
		(SELECT date_fld
			FROM Table_Name
			WHERE value_fld <> 'A')
	ORDER BY date_fld
HTH,
Chad


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.
_________________________________
There are 2 types of people in the world:
    Those who need closure
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform