Home › GATE CSE › computerscience › Database Management Systems › Why is `SELECT branch, name, AVG(salary) FROM em…
Why is `SELECT branch, name, AVG(salary) FROM employees GROUP BY branch` illegal in standard SQL?
AAVG cannot be used with GROUP BY
B`name` is non-aggregated but not in GROUP BY
Cbranch and name conflict in the WHERE clause
Dthe query is missing a HAVING clause
Answer & Solution
Correct answer: B. `name` is non-aggregated but not in GROUP BY
Each branch has many employees, so each group has many names. SQL requires that every non-aggregated SELECT column appear in GROUP BY, so there is one value per group to display. Either add `name` to GROUP BY (changing the grouping), wrap it in an aggregate like MAX(name), or remove it from SELECT.
Related questions
The main reasons production DBMSs avoid shadow paging in favour of WAL are that shadow pagWhat is the purpose of a Compensation Log Record (CLR) in ARIES?ARIES recovery is structured as exactlyFuzzy checkpoints differ from naive checkpoints byIn standard log-based recovery, the order of operations isAfter a crash, with checkpointing, the recovery system scans the logA complete log record for a write operation includesPer WAL semantics, a transaction is officially committed at the moment