scalar subqueries

A subquery in the SELECT clause of the main query is called a scalar subquery.

This is a single row, single column query, which looks just like a column or function in the SELECT clause. The structure is:
[click to continue…]

{ 0 comments }

A correlated subquery is a type of nested subquery that uses columns from the outer query in its WHERE clause.

For example, a query to list employees whose salary is more than their department’s average:

[click to continue…]

{ 3 comments }

A subquery is – to put it simply – a query within a query.

What purpose does a subquery serve?

A subquery may be needed when it takes more than a single step to reach the answer.

Suppose we need to find all employees who work in the same department as KING. We need to:

[click to continue…]

{ 0 comments }