Skip to content
Activities · Activity 1.3

Q.Using the table EMPLOYEE from CARSHOWROOM database, write SQL queries for the following:

(a) Display employee name and the last 2 characters of his EmpId.
(b) Display designation of employee and the position of character ‘e’ in designation, if present.
CBSENCERTSubjective· 3mImportance★★★★★est
15% · 6/40 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 →

RIGHT(EmpId, 2) extracts the last two characters of the employee ID; INSTR(Designation, 'e') returns the 1-based position of the first 'e' (or 0 if absent) — both on the real EMPLOYEE table.

This is a code/query task on the EMPLOYEE table of CARSHOWROOM:

EmpIDEmpNameDOBDOJDesignationSalary
E001Rushil1994-07-102017-12-12Salesman25550
E002Sanjay1990-03-122016-06-05Salesman33100
E003Zohar1975-08-301999-01-08Peon20000
E004Arpit1989-06-062010-12-02Salesman39100
E006Sanjucta1985-11-032012-07-01Receptionist27350
E007Mayank1993-04-032017-01-01Salesman27352
E010Rajkumar1987-02-262013-10-23Salesman31111

(a) RIGHT(string, N) returns the last N characters:

SELECT EmpName, RIGHT(EmpId, 2) FROM EMPLOYEE;

Each EmpID's last 2 characters are just its numeric suffix — E001→"01", E002→"02", E003→"03", E004→"04", E006→"06", E007→"07", E010→"10".

(b) INSTR(string, substring) returns the 1-based position of the first match, or 0 if absent:

SELECT Designation, INSTR(Designation, 'e') FROM EMPLOYEE;
``` …

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.