Skip to content
Question

Q.Which of the following is not a valid aggregate function in MYSQL? (A) COUNT ( ) (B) SUM ( ) (C) MAX ( ) (D) LEN ( )

CBSECBSE Class XII Board 2023MCQ· 1mImportance★★★★★
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

LEN() is not a valid aggregate function in MySQL; it is a scalar string function that returns the length of a single string.

In the world of databases, particularly when working with SQL (Structured Query Language) like MySQL, we often need to perform calculations that summarize data across multiple records. This is where aggregate functions come into play. These functions operate on a collection of rows and return a single value that represents a summary of that collection. Think of them as tools to get insights like "total sales," "average score," or "number of students."

Let's break down what aggregate functions are and then examine the options provided.

Understanding Aggregate Functions

An aggregate function processes a group of input values (from multiple rows) and produces a single output value. They are typically used with the SELECT statement and often combined with the GROUP BY clause to perform calculations on specific groups of data. Without GROUP BY, the aggregate function treats the entire result set as a single group.

Common aggregate functions include:

  • COUNT(): This function counts the number of rows or non-NULL values in a specified column. For example, COUNT(*) counts all rows, while COUNT(column_name) counts rows where column_name is not NULL.
  • SUM(): This function calculates the total sum of a numeric column. It's useful for finding totals like the sum of quantities or prices.
  • AVG(): This function computes the average (arithmetic mean) of a numeric column. It's perfect for finding average scores, average salaries, etc.
  • MAX(): This function finds the maximum value in a specified column. It can be used with numeric, string, or date/time data types to find the highest value.
  • MIN(): This function finds the minimum value in a specified column. Similar to MAX(), it works with numeric, string, or date/time data types to find the lowest value.
Important

The key characteristic of an aggregate function is that it takes multiple input values (from a set of rows) and returns a single, summarized output value.

Analyzing the Options

Now, let's look at the functions given in the question:

  • (A) COUNT(): As discussed, COUNT() is a fundamental aggregate function. It is used to count the number of rows that match a specified criterion. For instance, SELECT COUNT(student_id) FROM Students; would tell you the total number of students. This is a valid aggregate function in MySQL.

  • (B) SUM(): SUM() is also a core aggregate function. It calculates the total sum of values in a numeric column. For example, SELECT SUM(amount) FROM Orders; would give you the total amount of all orders. This is a valid aggregate function in MySQL. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.