CS FundamentalsVery hardGATE CS (PYQ pattern)
Which of the following statements about standard SQL are correct? I. A column alias defined in the SELECT list can be used in ORDER BY. II. A column alias defined in the SELECT list can be used in the WHERE clause of the same query block. III. A SELECT with GROUP BY may not list a non-aggregated column that is neither grouped nor functionally dependent on the grouping columns. IV. HAVING may use an aggregate that does not appear in the SELECT list.
- A. I and II only
- B. II, III and IV only
- C. I and III only
- D. I, III and IV only
Correct answer: D. I, III and IV only
WHERE is evaluated before the SELECT list, so aliases are not visible there (II is false). ORDER BY runs after SELECT and may use aliases, the grouping rule in III is the standard one, and HAVING can filter on any aggregate.
More DBMS and SQL questions
- X1(a): 1, 1, 2, 2, 3, 4 and Y1(a): 2, 4, 5. Let p = rows from SELECT a FROM X1 WHERE a NOT IN (SELECT a FROM Y1) and q = rows from SELECT…
- Tables: P(id); C(id, p) with p referencing P(id) ON DELETE CASCADE; G(id, c) with c referencing C(id) ON DELETE SET NULL. Rows: P = {1…
- Optimistic concurrency control with backward validation. Transactions (start, validation, finish times; read set; write set): T1 (0, 4, 5…
- A two-phase commit has 1 coordinator and 5 participants and uses the read-only optimisation. All 5 receive PREPARE. Three vote YES, one…
- A linear hashing file starts with 2 buckets (hash h0 = k mod 2, then h1 = k mod 4, h2 = k mod 8, ...), a bucket holds 2 keys before it…
- A B+ tree index is built on (a, b) in this order. For which of these predicates can a search descend directly to a contiguous range of…