WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

PostgreSQL · Basic · question 13 of 100

What are the aggregate functions available in PostgreSQL, and what are their purposes?

📕 Buy this interview preparation book: 100 PostgreSQL questions & answers — PDF + EPUB for $5

PostgreSQL provides a wide range of aggregate functions to perform calculations on groups of values rather than individual values returned by a SELECT statement. The available aggregate functions in PostgreSQL include:

1. AVG(): This function returns the average of a set of values.

Example usage:

SELECT AVG(price) FROM products;

2. SUM(): This function returns the sum of a set of values.

Example usage:

SELECT SUM(quantity) FROM orders;

3. MIN(): This function returns the minimum value of a set of values.

Example usage:

SELECT MIN(price) FROM products;

4. MAX(): This function returns the maximum value of a set of values.

Example usage:

SELECT MAX(price) FROM products;

5. COUNT(): This function returns the number of rows or non-null values in the specified column.

Example usage:

SELECT COUNT(*) FROM users;

6. BIT_AND(): This function returns the bitwise AND of all input values.

Example usage:

SELECT BIT_AND(value) FROM my_table;

7. BIT_OR(): This function returns the bitwise OR of all input values.

Example usage:

SELECT BIT_OR(value) FROM my_table;

8. BOOL_AND(): This function returns true if all input values are true, and false otherwise.

Example usage:

SELECT BOOL_AND(is_active) FROM users;

9. BOOL_OR(): This function returns true if at least one input value is true, and false otherwise.

Example usage:

SELECT BOOL_OR(is_active) FROM users;

10. ARRAY_AGG(): This function returns an array of values for a given column.

Example usage:

SELECT ARRAY_AGG(price) FROM products;

These are just a few of the aggregate functions provided by PostgreSQL. Each function performs a specific calculation on a set of values, making it easier to retrieve the desired information from your database.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic PostgreSQL interview — then scores it.
📞 Practice PostgreSQL — free 15 min
📕 Buy this interview preparation book: 100 PostgreSQL questions & answers — PDF + EPUB for $5

All 100 PostgreSQL questions · All topics