Home › GATE CSE › computerscience › Database Management Systems › In a SELECT with GROUP BY, the correct way to ke…
In a SELECT with GROUP BY, the correct way to keep only groups whose average salary exceeds 50000 is
Ause WHERE AVG(salary) > 50000 before GROUP BY
Buse ORDER BY AVG(salary) > 50000
Cuse DISTINCT to filter the groups
Duse HAVING AVG(salary) > 50000 after GROUP BY
Answer & Solution
Correct answer: D. use HAVING AVG(salary) > 50000 after GROUP BY
HAVING is the clause that filters AFTER aggregation. WHERE filters individual rows BEFORE grouping (and aggregate functions are not allowed in WHERE for that reason). ORDER BY only sorts; DISTINCT only removes duplicate rows.
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