Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Count for condition and total
Message
From
30/04/2009 17:02:40
 
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:
01397324
Message ID:
01397333
Views:
33
>>I'm trying to write a select statement to give me the number of records for a given date, along with the number that meet a certain criteria specified by a view parameter:
>>
Date       Code
>>3/1/2009 A
>>3/1/2009 P
>>3/1/2009 W
>>3/1/2009 P
>>
Giving a result of
>>
>>Param Date     Met Total
>>"A"   3/1/2009  1  4
>>"W"   3/1/2009  1  4
>>"P"   3/1/2009  2  4
>>
>
>What is your database? In SQL Server it's a piece of cake using Windows functions (SQL Server 2005 and up).
>
>In VFP we need to use derived tables:
>
>
>select T.Param, T.Date, Count(*) as Met, Der.Total from myTable T inner join (select Date, count(*) as Total from myTable group by Date where Date = ?v_Date) Der 
>ON T.Date = Der.Date
>group by T.Date, T.Param where T.Date = ?v_Date
Using VFP 8.1. Which may answer this question: is joining to a Select a new feature in VFP 9? At the moment it's throwing an error on that line.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform