Skip to content
Question
Q.

Excellent Consultancy Pvt. Ltd. maintains two tables for all its employees.

Table : Employee

Employee_idFirst_nameLast_nameSalaryJoining_dateDepartment
E101MonikaDas1000002019-01-20Finance
E102MehekVerma6000002019-01-15IT
E103MananPant8900002019-02-05Banking
E104ShivamAgarwal2000002019-02-25Insurance
E105AlishaSingh2200002019-02-28Finance
E106PoonamSharma4000002019-05-10IT
E107AnshumanMishra1230002019-06-20Banking

Table : Reward

Employee_idDate_rewardAmount
E1012019-05-111000
E1022019-02-155000
E1032019-04-222000
E1062019-06-208000

Write suitable SQL queries to perform the following task : (i) Change the Department of Shivam to IT in the table Employee. (ii) Remove the record of Alisha from the table Employee. (iii) Add a new column Experience of integer type in the table Employee. (iv) Display the first name, last name and amount of reward for all employees from the tables Employee and Reward. (v) Display first name and salary of all the employees whose amount is less than 2000 from the tables Employee and Reward. OR Write suitable SQL queries for the following task : (i) Display the year of joining of all the employees from the table Employee. (ii) Display each department name and its corresponding average salary. (iii) Display the first name and date of reward of those employees who joined on Monday from the tables Employee and Reward. (iv) Display sum of salary of those employees whose reward amount is greater than 3000 from the tables Employee and Reward. (v) Remove the table Reward.

CBSECBSE Class XII Board 2024Subjective· 5mImportance★★★★★
🔒 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 →

Part (a): UPDATE, DELETE, ALTER ADD, LEFT JOIN, and filtered INNER JOIN. Part (b): YEAR(), GROUP BY AVG, Monday-join (0 rows), SUM(Salary) where Amount>3000 = 1000000, DROP TABLE.

Part (a)

(i) Modify one row with UPDATE, identifying Shivam:

UPDATE Employee SET Department='IT' WHERE First_name='Shivam';

(ii) Remove a row with DELETE:

DELETE FROM Employee WHERE First_name='Alisha';

(iii) Add a new integer column with ALTER TABLE:

ALTER TABLE Employee ADD Experience INT;

(iv) "For all employees" means every employee must appear even without a reward, so use a LEFT JOIN on Employee_id; missing rewards show NULL.

(v) "Whose amount is less than 2000" needs a reward, so an INNER JOIN with WHERE Amount<2000. From the data only E101 (Monika, reward 1000) qualifies; E103's reward is exactly 2000, which is not less than 2000.

UPDATE Employee SET Department='IT' WHERE First_name='Shivam';
DELETE FROM Employee WHERE First_name='Alisha';
ALTER TABLE Employee ADD Experience INT;
SELECT E.First_name, E.Last_name, R.Amount
FROM Employee E LEFT JOIN Reward R ON E.Employee_id=R.Employee_id;
SELECT E.First_name, E.Salary
FROM Employee E INNER JOIN Reward R ON E.Employee_id=R.Employee_id
WHERE R.Amount < 2000; …

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.