[
https://issues.apache.org/jira/browse/CASSANDRA-4914?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14112192#comment-14112192
]
Brian Hess commented on CASSANDRA-4914:
----------------------------------------
[~slebresne] - what does SELECT AVG(*) FROM supposed to mean? If I have a
table called MYDATA with schema (pkey INT, ccol INT, x INT, y INT, PRIMARY KEY
((pkey), ccol)), then what would "SELECT AVG(*) FROM mydata WHERE pkey=1 AND
ccol=1" return? I think you need to include a column to AVG, like "SELECT
AVG(x) FROM mydata WHERE pkey=1 AND ccol=1" or "SELECT AVG(x), AVG(y) FROM
mydata WHERE pkey=1 AND ccol=1".
COUNT() is a special case. COUNT(*) really is the same as COUNT(1), because
you are just counting the number of rows. Note, though, that COUNT(x) is not
the same as COUNT(*) since COUNT() will not count things that are NULL, so
COUNT(*) will count all rows but COUNT(x) will only count rows where X is not
NULL. At least, according to SQL.
> Aggregation functions in CQL
> ----------------------------
>
> Key: CASSANDRA-4914
> URL: https://issues.apache.org/jira/browse/CASSANDRA-4914
> Project: Cassandra
> Issue Type: New Feature
> Reporter: Vijay
> Assignee: Benjamin Lerer
> Labels: cql, docs
> Fix For: 3.0
>
> Attachments: CASSANDRA-4914.txt
>
>
> The requirement is to do aggregation of data in Cassandra (Wide row of column
> values of int, double, float etc).
> With some basic agree gate functions like AVG, SUM, Mean, Min, Max, etc (for
> the columns within a row).
> Example:
> SELECT * FROM emp WHERE empID IN (130) ORDER BY deptID DESC;
>
> empid | deptid | first_name | last_name | salary
> -------+--------+------------+-----------+--------
> 130 | 3 | joe | doe | 10.1
> 130 | 2 | joe | doe | 100
> 130 | 1 | joe | doe | 1e+03
>
> SELECT sum(salary), empid FROM emp WHERE empID IN (130);
>
> sum(salary) | empid
> -------------+--------
> 1110.1 | 130
--
This message was sent by Atlassian JIRA
(v6.2#6252)