Question
In SQL, are we limited to only one aggregate function per query?
Answer
No, you can list more than one aggregate function after a SELECT
, and there is no strict limit to this. For example,
SELECT COUNT(*), SUM(col) FROM table;
However, as you apply more aggregate functions within a query, it can start to become more complex, and the results might not be easy to read with all the information. So, it is possible to do this, but it may not be the best choice to combine so many aggregate functions in a single query.
Typically, for most of the exercises throughout the course, we utilize one aggregate function per query, and sometimes might use more than one.