Informatics Practices
Assertion (A): All aggregate functions except count(*) ignore null values in their input collection.
Reasoning (R): SUM, AVG, MIN, and MAX can only be used with numeric columns.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
SQL Queries
1 Like
Answer
A is true but R is false.
Explanation
In SQL, aggregate functions like SUM, AVG, MIN, and MAX ignore NULL values in their calculations. The function COUNT(*), however, counts all rows along with NULL values in the table. The SUM and AVG functions can take arguments of only integer type, and can be used with numeric columns. While MAX and MIN functions can be used with various data types, including numeric, string, and datetime columns.
Answered By
1 Like
Related Questions
Assertion (A): The INTERSECT operator returns all rows that are in both result sets.
Reasoning (R): The UNION and INTERSECT yields same output.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Assertion (A): GROUP BY clause is always preceded by ORDER BY clause in a SELECT statement.
Reasoning (R): ORDER BY clause always follows other clauses.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
ABC Associates has over 2000 employees on its roll and deals with customer support services. Help the company to perform associated operations for calculating the salaries (stored in Sal column) of their employees and to perform relevant analysis on the fetched data from the SQL database/table.
How can we retrieve records where salary is between 1000 and 2000?
Select all records where dept no of both emp and dept table matches.