Aggregating cycling data

An aggregate function operates on a set of rows. The aggregate function receives values for each row and returns one value for all of the rows.

This section shows queries that use the aggregate functions. Each query is followed by the returned output.

This query uses the AVG function to return the average team racing time:

SELECT AVG(cyclist_time_sec) AS Average
FROM cycling.team_average
WHERE team_name = 'UnitedHealthCare Pro Cycling Womens Team';

Output:

 average
---------
   11474

(1 rows)

This query uses the COUNT function to return the number of cyclists in the specified team:

SELECT COUNT(cyclist_name) AS Row_Count
FROM cycling.team_average
WHERE team_name = 'UnitedHealthCare Pro Cycling Womens Team';

Output:

 row_count
-----------
         3

(1 rows)

This query uses the MIN function to return the fastest team racing time:

SELECT MIN(cyclist_time_sec) AS Fastest
FROM cycling.team_average
WHERE team_name = 'UnitedHealthCare Pro Cycling Womens Team';

Output:

 fastest
---------
   11449

(1 rows)

This query uses the MAX function to return the slowest team racing time:

SELECT MAX(cyclist_time_sec) AS Slowest
FROM cycling.team_average
WHERE team_name = 'UnitedHealthCare Pro Cycling Womens Team';

Output:

 slowest
---------
   11490

(1 rows)

This query uses the SUM function to return the total team racing times:

SELECT SUM(cyclist_time_sec) AS Total_Time
FROM cycling.team_average
WHERE team_name = 'UnitedHealthCare Pro Cycling Womens Team';

Output:

 total_time
------------
      34424

(1 rows)

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com