COMPUTER SCIENCE AND ENGINEERING
SQL
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Aggregate functions can be used in WHERE clause.SELECT Id, EName, Salary, Dept FROM Employee E1 WHERE Salary = MAX(Salary);
|
|
Aggregate functions can be used in WHERE clause even if GROUP BY is used.SELECT DEPT, SUM(Salary) FROM Employee WHERE SUM(Salary) > 90000 GROUP BY DEPT
|
|
Nested aggregate function can be used in SELECT clause without GROUP BY clause.SELECT MAX(AVG(Salary)) FROM Employee;
|
|
Order By cannot be used on columns on which Grouping is not being done.SELECT Dept, SUM(Salary) FROM Employee GROUP BY Dept ORDER BY Designation;
|
Detailed explanation-1: -Answer: D. Group functions cannot be used in WHERE clause. The can appear in SELECT, HAVING and ORDER BY clause.
Detailed explanation-2: -Group functions on columns cannot be accurately used on columns that contain NULL values.
Detailed explanation-3: -In MySQL, when you try to select a column that isn’t used in the GROUP BY clause, or in an aggregate function inside the statement, it is not a valid statement according to SQL standard and will cause an error.
Detailed explanation-4: -The Group By statement is used to group together any rows of a column with the same value stored in them, based on a function specified in the statement. Generally, these functions are one of the aggregate functions such as MAX() and SUM(). This statement is used with the SELECT command in SQL.