All Exams Test series for 1 year @ ₹349 only
Question

In SQL, _______ is an Aggregate function.

The correct answer is

AVG

Understanding SQL Aggregate Functions

In SQL (Structured Query Language), aggregate functions perform a calculation on a set of rows and return a single value. These functions are often used with the GROUP BY clause to perform calculations on groups of rows, but they can also operate on the entire set of selected rows.

Let's examine the provided options to identify which one is an aggregate function:

  • SELECT: SELECT is a SQL statement used to retrieve data from one or more tables. It is not a function that performs calculations on data.
  • CREATE: CREATE is a SQL statement used to create new database objects, such as tables, databases, indexes, or views. It is part of the Data Definition Language (DDL) and is not an aggregate function.
  • AVG: AVG() is an SQL function that calculates the average value of a numeric column in a set of rows. This is a standard aggregate function.
  • MODIFY: MODIFY is not a standard standalone SQL statement or aggregate function in most common SQL dialects. Keywords like ALTER TABLE are used to modify table structures, and UPDATE is used to modify data, but neither is an aggregate function.

Based on this analysis, AVG is the only option that represents a standard SQL aggregate function.

Common SQL Aggregate Functions

Some commonly used SQL aggregate functions include:

  • COUNT(): Counts the number of rows.
  • SUM(): Calculates the sum of values in a numeric column.
  • AVG(): Calculates the average value of a numeric column.
  • MIN(): Finds the minimum value in a column.
  • MAX(): Finds the maximum value in a column.

Revision Table: SQL Concepts

Concept Description Example (Function/Statement)
Aggregate Function Performs calculation on a set of rows, returns single value AVG(), SUM(), COUNT()
SQL Statement An instruction given to the database to perform an action SELECT, CREATE, INSERT, UPDATE, DELETE
DDL Statement Used to define database structure CREATE, ALTER, DROP
DML Statement Used to manipulate data SELECT, INSERT, UPDATE, DELETE

Additional Information: Functions vs. Statements in SQL

It's important to distinguish between SQL statements and SQL functions.

  • Statements like SELECT, CREATE, INSERT, UPDATE, DELETE are commands that perform specific actions on the database or data.
  • Functions like AVG(), SUM(), UPPER(), NOW() are operations that return a value. Aggregate functions are a specific type of function that operates on a collection of rows.

In this question, AVG is a function, specifically an aggregate function, whereas SELECT and CREATE are SQL statements.

Was this answer helpful?

Important Questions from SQL

  1. Match the following -

    List IList II
    (a)DDL(i)LOCK TABLE
    (b)DML(ii)COMMIT
    (c)TCL(iii)Natural Difference
    (d)Binary operation(iv)REVOKE
  2. In SQL, which of the following command is used to modify a column in a table?

  3. Which of the following keyword is used to eliminate duplicate records in SQL?

  4. _______ SQL command changes one or more fields in a record.

  5. Given two relations R 1(A, B) and R 2(C, D), the result of following query

    Select distinct A, B

    from R 1, R 2

    is guaranteed to be same as R 1 provided one of the following condition is satisfied.

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App