SQL & Queries

Answer & solution
Official answer: B
The uncorrelated subquery averages salary across the entire emp relation, with no gender or department filter. The outer query counts female employees above that company-wide average, grouped by department. Thus B. Departments with no qualifying rows are omitted rather than returned with count 0. The printed double-quoted female is understood as an intended string literal; standard SQL uses single quotes, while double quotes ordinarily delimit identifiers.
The inner SELECT has no reference to the outer row, so its scalar mean is computed over all emp rows. The gender test is outside it and does not restrict that mean. GROUP BY affects the final count, not the subquery's population. This distinction separates all four options.

