Aggregate Functions Interview Questions

    Question 1: Purpose of Aggregate Functions

    What is the main purpose of aggregate functions in SQL?

    Question 2: COUNT 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 3: Counting Rows

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

    Question 4: SUM 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 5: MIN 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 6: Calculating Average

    Which aggregate function calculates the average salary of employees?

    Question 7: Combined 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 8: Finding the Highest Salary

    Which query finds the maximum salary from the employees table?

    Question 9: Ignoring NULL in Aggregates

    How do aggregate functions handle NULL values?

    Question 10: Combining Aggregates in One Query

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