Aggregate Functions Interview Questions

    Question 1Purpose of Aggregate Functions

    What is the main purpose of aggregate functions in SQL?

    Question 2COUNT Function Variations

    From an employees table (emp_id, name, department, salary, phone), write a query to show total number of employees, number of employees with phone numbers, and number of unique departments.

    Question 3Counting Rows

    Which query counts the total number of students in the students table?

    Question 4SUM and AVG Functions with Grouping

    From a sales table (sale_id, salesperson_id, product_id, quantity, unit_price), calculate total sales amount and average sale amount per salesperson.

    Question 5MIN and MAX Functions with Date Operations

    From an orders table (order_id, customer_id, order_date, total_amount), find the earliest order date, latest order date, lowest order amount, and highest order amount for each customer.

    Question 6Calculating Average

    Which aggregate function calculates the average salary of employees?

    Question 7Combined Aggregate Functions with Conditions

    From a products table (product_id, product_name, category, price, stock_quantity), show category-wise statistics: total products, average price, minimum price, maximum price, and total stock, but only for categories with more than 2 products.

    Question 8Finding the Highest Salary

    Which query finds the maximum salary from the employees table?

    Question 9Ignoring NULL in Aggregates

    How do aggregate functions handle NULL values?

    Question 10Combining Aggregates in One Query

    Which query shows the minimum and maximum salary from the employees table?