Join EmployeeInfo, DeptInfo and SalaryInfo, and return EmpID, Name, DeptName and HRA (house rent allowance) for every employee whose department is located in Bangalore or Chennai. Order the result by EmpID ascending.
Input Table(s)
EmployeeInfo
| Column | Type | Meaning |
|---|
| EmpID | INT | Employee id |
| Name | VARCHAR | Employee name |
| DeptID | INT | The employee's department, references DeptInfo.DeptID |
Primary key: EmpID.
DeptInfo
| Column | Type | Meaning |
|---|
| DeptID | INT | Department id |
| DeptName | VARCHAR | Department name |
| Location | VARCHAR | City where the department is located, such as 'Bangalore', 'Chennai', 'Mumbai' or 'Delhi' |
Primary key: DeptID.
SalaryInfo
| Column | Type | Meaning |
|---|
| EmpID | INT | Employee id, references EmployeeInfo.EmpID |
| HRA | INT | The employee's house rent allowance |
Primary key: EmpID (exactly one salary row per employee).
Output Contract
Columns in this order: EmpID, Name, DeptName, HRA. Return one row per qualifying employee, ordered by EmpID ascending. EmpID is unique, so the order is unique. No rounding is needed.
Example
Input EmployeeInfo:
| EmpID | Name | DeptID |
|---|
| 1 | Asha | 10 |
| 2 | Ravi | 20 |
| 3 | Meena | 30 |
| 4 | Karan | 10 |
| 5 | Priya | 40 |
Input DeptInfo:
| DeptID | DeptName | Location |
|---|
| 10 | Finance | Bangalore |
| 20 | Marketing | Mumbai |
| 30 | Engineering | Chennai |
| 40 | Operations | Delhi |
Input SalaryInfo:
| EmpID | HRA |
|---|
| 1 | 12000 |
| 2 | 9000 |
| 3 | 15000 |
| 4 | 11000 |
| 5 | 8000 |
Expected output:
| EmpID | Name | DeptName | HRA |
|---|
| 1 | Asha | Finance | 12000 |
| 3 | Meena | Engineering | 15000 |
| 4 | Karan | Finance | 11000 |
Asha and Karan work in Finance (Bangalore) and Meena works in Engineering (Chennai), so they are returned. Ravi's department is in Mumbai and Priya's is in Delhi, so both are left out.
Constraints and Clarifications
-
There are at most 10,000 employees.
-
Each
EmpID
is unique and maps to exactly one
SalaryInfo
row.
-
Each
DeptID
in
DeptInfo
is unique.
-
Location
holds plain city names. Match 'Bangalore' and 'Chennai' exactly as written.
-
An employee whose department is missing from
DeptInfo
, or whose department has a NULL
Location
, is not located in either city and is left out.