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
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:
| EmpID | EmpName | DOB | DOJ | Designation | Salary |
|---|---|---|---|---|---|
| E001 | Rushil | 1994-07-10 | 2017-12-12 | Salesman | 25550 |
| E002 | Sanjay | 1990-03-12 | 2016-06-05 | Salesman | 33100 |
| E003 | Zohar | 1975-08-30 | 1999-01-08 | Peon | 20000 |
| E004 | Arpit | 1989-06-06 | 2010-12-02 | Salesman | 39100 |
| E006 | Sanjucta | 1985-11-03 | 2012-07-01 | Receptionist | 27350 |
| E007 | Mayank | 1993-04-03 | 2017-01-01 | Salesman | 27352 |
| E010 | Rajkumar | 1987-02-26 | 2013-10-23 | Salesman | 31111 |
(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.