Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SELECT and count()
Message
From
17/12/1998 11:16:23
 
 
To
17/12/1998 10:28:30
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00168507
Message ID:
00168527
Views:
19
Aggregation functions in SQL, including COUNT, are integrally tied to the associated GROUP BY clause. Since you grouped by an expression containing fields only in t1 that's what guides the count regardless of what you put as the parameter in the COUNT aggregation function.

>I have this SELECT:
>SELECT (t1.f1+t1.f2+t1.f3) AS cGroup, COUNT(t1.f1) AS n1, COUNT(t2.f1) AS n2 ;
>FROM t1 LEFT JOIN t2 ON <....>=<...> WHERE ......
>GROUP BY 1
>
>The resulting cursor has same value for both n1 and n2 which is not right because t2 has less number of these records. Is it possible to have such SELECT working OK?
>TIA Mark
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform