Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Count for condition and total
Message
De
30/04/2009 17:02:40
 
 
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:
01397324
Message ID:
01397333
Vues:
34
>>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform