I'm using the same scott schema.the questiion goes like this. Display the empno,sal,TA,DA,HRA,Total allowances,Insurance,TDS,Netdeductions,Netsal with descriptive labels.
here Ta is 30% of sal, DA is 40% of sal,hra is 50% of sal, insurance is 5%sal and tds is 5%sal. Total allowances is ta + da+ hra. total deductions is ins + tds now netsal is (sal + allowances-total deductions)
I'm trying to achieve this using with statement
WITH T1 AS
(SELECT (30 / 100 * SAL) AS TA FROM EMP),
T2 AS
(SELECT (40 / 100 * SAL) AS DA FROM EMP),
T3 AS
(SELECT (50 / 100 * SAL) AS HRA FROM EMP)
SELECT Empno, TA, DA, HRA, (ta + da + hra)
FROM EMP, T1, T2, T3
group by empno;
something like this.The logic is wrong I can understand that.