logo

CuriousTab

CuriousTab

Discussion


Home Interview Technology Comments

  • Question
  • What are aggregate functions in SQL? What are those functions?


  • Correct Answer
  • Aggregate functions in SQL are used to perform calculation on data These functions are inbuilt in SQL and return a single value SUM( ) SUM function returns the sum or addition of all NOT NULL values of a column For eg I have a Table employee with the fields id, name, salary and I want the sum of all salaries, I can use SUM function as shown SELECT SUM(emp_salary) from employee; Hence, if my column emp_salary has values 20,000, 22,000, 21,000; the output will be 63,000 AVG( ) AVG function returns the average of all NOT NULL values of a column For eg I have a Table employee with the fields id, name, salary and I want the average of all salaries, I can use AVG function as shown SELECT AVG(emp_salary) from employee; Hence, if my column emp_salary has values 20,000, 22,000, 21,000; the output will be 21,000 COUNT( ) COUNT function returns the number of rows or values of a table For eg I have a Table employee with the fields id, name, salary and I want the count of all rows, I can use COUNT function as shown SELECT COUNT(*) from employee; Max ( ) and Min ( ) MAX function returns the largest value of a column in a table For eg I have a Table employee with the fields id, name, salary and I want the maximum salary of an employee, I can use MAX function as shown SELECT MAX(emp_salary) from employee; Hence, if my column emp_salary has values 20,000, 22,000, 21,000; the output will be 22,000 MIN function returns the smallest value of a column in a table For eg I have a Table employee with the fields id, name, salary and I want the minimun salary of an employee, I can use MIN function as shown SELECT MIN(emp_salary) from employee; Hence, if my column emp_salary has values 20,000, 22,000, 21,000; the output will be 20,000 


  • Technology problems


    Search Results


    • 1. Explain Row level and statement level trigger.
    • Discuss
    • 2. Explain the difference between trigger and stored procedure.
    • Discuss
    • 3. What do you mean by Redo Log file mirroring ?
    • Discuss
    • 4. What are the varoius components of physical database structure of Oracle database?
    • Discuss
    • 5. What is a sub query? What are its various types?
    • Discuss
    • 6. What are Number Functions in SQL?
    • Discuss
    • 7. What are the basic SQL*Plus commands?
    • Discuss
    • 8. What is AFIEDT.BUF?
    • Discuss
    • 9. How to Add a new column to an existing table?
    • Discuss
    • 10. How to recover a dropped table?
    • Discuss


    Comments

    There are no comments.

Enter a new Comment