Skip to content
Worked Examples · Example 9.6

Q.The following query selects the name and department number of all those employees who are earning salary between 20000 and 50000 (both values inclusive).

Puducherry TnboardTextbookSubjective· 2mImportance★★★★★
12% · 11/95 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

BETWEEN 20000 AND 50000 is inclusive on both ends. Run against the chapter's own EMPLOYEE table (Table 9.8), WHERE Salary BETWEEN 20000 AND 50000 (equivalently Salary >= 20000 AND Salary <= 50000) picks 6 of the 10 employees.

Concept: selection then projection

Relational algebraSQL clausePurpose
Selection σWHEREwhich rows survive
Projection πcolumn list after SELECTwhich columns are shown
SELECT Ename, DeptId
FROM EMPLOYEE
WHERE Salary >= 20000 AND Salary <= 50000;

Checking every row of Table 9.8

EnameSalaryIn [20000, 50000]?
Aaliya10000no — below
Kritika60000no — above
Shabbir45000yes
Gurpreet19000no — below
Joseph34000yes
Sanya48000yes
Vergese15000no — below
Nachaobi29000yes
Daribha42000yes
Tanya50000yes — boundary included

Output (6 rows):

+----------+--------+
| Ename    | DeptId |
+----------+--------+
| Shabbir  | D01    |
| Joseph   | D03    |
| Sanya    | D02    |
| Nachaobi | D05    |
| Daribha  | D04    | …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.