Sobes.tech
Junior

Name aggregate functions in the context of working with databases.

sobes.tech AI

Answer from AI

Aggregate functions in databases are functions that take a set of values and return a single summary value. They are often used to compute statistics on data.

Main aggregate functions:

  • COUNT() — counts the number of rows or values.
  • SUM() — calculates the sum of numeric values.
  • AVG() — computes the average value.
  • MIN() — finds the minimum value.
  • MAX() — finds the maximum value.

Example query that counts the number of users and the average age:

SELECT COUNT(*) AS total_users, AVG(age) AS average_age FROM users;