Hi all...
This is my query (Helped By Mr. Manoj) in previous post....
Select *, (x.A+x.B-x.C) as "D" From (
select E.EmpCode,
(select count (D.id) from Dept D where D.Location = E.Location) as "A"),
(select count (D.id) from Add D where D.Location = E.Location) as "B"),
(select count (D.id) from Dept D where D.DeptName = E.DeptName) as "C")
from Employees E) x
Now ; in this query ; How do I get column-wise total ??
Data -
| EmpCode | A | B | C | D=A+B-C |
| 100A | 2 | 4 | 7 | 2+4-7 = -1 |
| 101A | 3 | 5 | 7 | 3+5-7 = 1 |
I want -
A = 2+3 = 5 ; B = 4+5 = 9 ; C = 7+7 = 14 ; D = -1 + 1 = 0
in the last record...
Please guide...
Raja TPosted Jul 30, 2015, 6:46 AM
I will sample.
EmpCode A B C
101A 10 20 30
101B 30 10 -20
Tot 40 30 10
Please confirm it is ok the ur output. If it is OK just use sum function in oracle.
If yes please check out bellow URL
http://www.w3schools.com/sql/sql_func_sum.asp
Riddhi ValechaPosted Jul 30, 2015, 6:17 AM
Raja TPosted Jul 30, 2015, 5:51 AM
https://msdn.microsoft.com/en-us/library/ms189305(v=sql.90).aspx