Query [message #190053] |
Tue, 29 August 2006 02:49 |
jai_162
Messages: 21 Registered: July 2006
|
Junior Member |
|
|
I have table emp with the following fields:
Empid EmpName EmpType sal.
Let say if the data is like this:
1 Jai A 200
2 Ram A 1800
3 Shyam B 4000
4 Bhim C 5000
I need the o/p in this form :
1 Jai A 200 2000(Sum of sal of Type )
Regards
Jai
|
|
|
Re: Query [message #190060 is a reply to message #190053] |
Tue, 29 August 2006 03:13 |
dhananjay
Messages: 635 Registered: March 2002 Location: Mumbai
|
Senior Member |
|
|
hi,
SELECT T.ID,T.NAME,T.JOB_TYPE,T.SAL,T1.TOT_SAL FROM TEST T,
(SELECT JOB_TYPE,SUM(SAL)TOT_SAL FROM TEST GROUP BY JOB_TYPE)T1
WHERE T1.JOB_TYPE=T.JOB_TYPE
ORDER BY T.ID
regards,
|
|
|
|
Re: Query [message #190121 is a reply to message #190070] |
Tue, 29 August 2006 05:40 |
ehegagoka
Messages: 493 Registered: July 2005
|
Senior Member |
|
|
hi!
you could also try this =)
FRGT_UAT@foscopy:SQL>select eid, ename,etype,
2 sum(sal) over (partition by etype order by eid) totsal
3 from test
4 /
EID ENAME ETYPE TOTSAL
---------- ---------- ---------- ----------
1 Jai A 200
2 Ram A 2000
3 Shyam B 400
4 Bhim C 500
FRGT_UAT@foscopy:SQL>
|
|
|
|