This is the question I have.
- Develop a salary sheet from emp table consisting of empno, ename, job, sal, comm, house rent computer at 25%, medical allowance of 15% of sal, transport allowance at 10% of sal and net salary consisting of sal, house rent, medical allowance, transport allowance and comm. of the employees.
I’m upto here.
SELECT EmpNo, Ename, Job, Sal, Comm,
Sal * 25 / 100 AS [house rent],
Sal * 15 / 100 AS [medical allowance],
Sal * 10 / 100 AS [transport allowance]
FROM Emp
which gives me this result-set

Now I’m stuck with calculating the net salary. (bold line in the above question) You have to add all the other expenses together and substract it from the Sal, right? But I don’t know how to do it in the query. Since house rent, transport allowance aren’t columns from the table, I cannot add them.
Any ideas on how to do this?
Thanks
You’d have to repeat the individual calculations, but…
Note that I’ve simplified the 3 calculations a bit. Since they’re all just percentages of the same raw value, it’s simpler to just add the individual component percentages rather than comput each seperately AGAIN and add them up.