Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sum and Count filtered records in an SQL statement
Message
 
To
26/11/1998 14:17:40
Marcelo Codino
Mystic & Faith - Sistemas -
Buenos Aires, Argentina
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00161836
Message ID:
00161848
Views:
19
>I have this SQL statement.The instruction works correctly but it sums and counts all table records.I want to do this but only with filetered records.Is it possible in the same instruction ?
>
>Thanks in advance.
>
>SELECT a.field1, a.field2, a.field3, a.field4 ;
>FROM mytable a ;
>SUM(a.field3) AS n_imp, ;
>COUNT(a.field1) AS n_can ;
>WHERE a.field2 = tcperiod ;
>AND a.field3 = tcyear ;
>ORDER BY a.field1 ;
>INTO CURSOR myCursor

Marcelo, did you try GROUP BY clause there?
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform