GATE / CS ARCHIVE

GATE CSE 1999 / QUESTION 22(a)

Query high-paid Calcutta employees

Database Management Systems · SQL & Queries · Full GATE CSE 1999 paper

GATE 1999, Q22(a) 2 marks · Descriptive
Report issue

SQL & Queries

Question 22(a), GATE 1999: EMP(Employee-no, Dept-no, Employee-name, Salary), DEPT(Dept-no, Dept-name, Location). Return employee names whose department is located at Calcutta and salary exceeds Rs.50,000.
Question 22(a), GATE 1999: EMP(Employee-no, Dept-no, Employee-name, Salary), DEPT(Dept-no, Dept-name, Location). Return employee names whose department is located at Calcutta and salary exceeds Rs.50,000.
Tap to enlarge
Answer & solution

Answer: Join EMP to DEPT and filter Location=Calcutta and Salary>50000. (no official key was published)

Use the common department identifier to join each employee to their department, then apply both predicates:

SELECT e."Employee-name"
FROM EMP AS e
JOIN DEPT AS d ON d."Dept-no" = e."Dept-no"
WHERE d.Location = 'Calcutta'
  AND e.Salary > 50000;

The double quotes are standard SQL identifier quoting, required here because the printed attribute names contain hyphens. A database schema using Employee_name and Dept_no may use those unquoted names instead. The inequality is strict: salary exactly 50000 does not qualify. The department join is essential because Location belongs to DEPT, not EMP. This returns one row per matching employee under the usual department-key assumption; two employees sharing a name may produce duplicate name values. Add DISTINCT only if the intended output is a set of distinct names rather than names per employee. SQL NULL salaries do not pass the comparison.

Original paper, page 9