Employee database SQL queries – November 2019

December 4, 2026 · Team EasyExamNotes · 2 min read (est.) · 0 comments

Share on WhatsApp

← RGPV CS-502 DBMS November 2019 solved question paper


November 2019 – Question 4(a)

Question (restated): Given employee(empname, street, city), works(empname, companyname, salary), company(companyname, city), manages(empname, management), write SQL to find First Bank Corporation employees, their addresses when annual salary exceeds 200000, and employees living in their company city.

Answer

Schema and assumptions

employee stores personal details, works associates employees with employers and salary, company records company locations, and manages stores management relationships. Assume salary is annual and empname identifies employees as intended by the question. No currency is specified.

1. Employees of First Bank Corporation

SELECT DISTINCT empname FROM works
WHERE companyname = 'First Bank Corporation';

The filter selects employment records for the specified company. DISTINCT prevents repeated names in the output.

2. Names and addresses above the salary threshold

SELECT DISTINCT e.empname, e.street, e.city
FROM employee e JOIN works w ON e.empname = w.empname
WHERE w.companyname = 'First Bank Corporation'
AND w.salary > 200000;

The join retrieves address information; the strict greater-than condition excludes a salary of exactly 200000.

3. Employees living in their company city

SELECT DISTINCT e.empname
FROM employee e JOIN works w ON e.empname = w.empname
JOIN company c ON w.companyname = c.companyname
WHERE e.city = c.city;

Worked example

Suppose Asha lives in Bhopal and earns 250000 at First Bank Corporation, Ravi lives in Indore and earns 200000 at the same company, and the company is located in Bhopal. Query 1 returns Asha and Ravi; query 2 returns only Asha and her address; query 3 returns Asha. The manages relation is unnecessary for these requests. If companies have multiple locations, query 3 matches any recorded location; a branch identifier would be needed to test the actual workplace.

← RGPV CS-502 DBMS November 2019 solved question paper

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion