MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

SQL

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
A window function cannot be referenced in the WHERE clause of the query in which it is selected.
A
TRUE
B
FALSE
C
Either A or B
D
None of the above
Explanation: 

Detailed explanation-1: -Window functions are permitted only in the SELECT list and the ORDER BY clause of the query. They are forbidden elsewhere, such as in GROUP BY, HAVING and WHERE clauses. This is because they logically execute after the processing of those clauses. Also, window functions execute after non-window aggregate functions.

Detailed explanation-2: -You can’t use window functions in WHERE, because the logical order of operations in an SQL query is completely different from the SQL syntax. The logical order of operations in SQL is: FROM, JOIN. WHERE.

Detailed explanation-3: -They reduce the result set based on the aggregation. Window partitions can be defined to form groups of rows. They compute a value for each and every row in the window. They require the ‘over’ clause.

Detailed explanation-4: -You cannot give a Window Function an alias.

There is 1 question to complete.