Worked Examples · Example 9.3
Q.Select names of all employees along with their annual income (calculated as Salary*12). While displaying the query result, rename the column EName as Name.
Uttarakhand UbseTextbookSubjective· 2mImportance★★★★★est
5% · 5/95 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 →Use column aliases (AS) to both compute Annual Income as Salary*12 and rename EName to Name. Run against the chapter's own EMPLOYEE table (Table 9.8), not a generic placeholder table.
An alias is a temporary name assigned to a column (or expression) in the result set — it doesn't change the underlying table, only how the column is displayed. You write it as expression AS alias_name.
The question asks for two things at once:
- A computed column:
Salary * 12, since annual income isn't stored directly. - A renamed column:
ENamedisplayed asName.
SELECT Ename AS Name, Salary*12 AS 'Annual Income'
FROM EMPLOYEE;
Quoting 'Annual Income' is necessary because the alias contains a space.
Running it on Table 9.8
The EMPLOYEE table was populated earlier in this section (Table 9.8):
| EmpNo | Ename | Salary | Bonus | DeptId |
|---|---|---|---|---|
| 101 | Aaliya | 10000 | 234 | D02 |
| 102 | Kritika | 60000 | 123 | D01 |
| 103 | Shabbir | 45000 | 566 | D01 |
| 104 | Gurpreet | 19000 | 565 | D04 |
| 105 | Joseph | 34000 | 875 | D03 |
| 106 | Sanya | 48000 | 695 | D02 |
| 107 | Vergese | 15000 | NULL | D01 |
| 108 | Nachaobi | 29000 | NULL | D05 |
| 109 | Daribha | 42000 | NULL | D04 |
| 110 | Tanya | 50000 | 467 | D05 |
Multiplying every Salary by 12 gives:
+----------+----------------+
| Name | Annual Income |
+----------+----------------+
| Aaliya | 120000 |
| Kritika | 720000 | …
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.