General information
Category:
Coding, syntax & commands
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only