SQL QUERY [message #664797] |
Fri, 04 August 2017 19:47 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](http://www.gravatar.com/avatar/b104f62e2a66837a4cb2b87e29f45a42?s=64&d=mm&r=g) |
shawaj
Messages: 89 Registered: January 2016
|
Member |
|
|
Hello everyone, I have the table T3 and i need data in this format.
ENAME SAL V_SAL
-----------------------------
A 10 10
B 20 30
C 30 60
D 40 100
Please help me.
Thanks in advance..
CREATE TABLE T3(ENAME VARCHAR2(20),SAL NUMBER);
INSERT INTO T3 VALUES('A',10);
INSERT INTO T3 VALUES('B',20);
INSERT INTO T3 VALUES('C',30);
INSERT INTO T3 VALUES('D',40);
COMMIT;
Select * from t3;
ENAME SAL
-------------------- ----------
A 10
B 20
C 30
D 40
|
|
|
|
|
|
Re: SQL QUERY [message #664807 is a reply to message #664799] |
Sat, 05 August 2017 07:28 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Solomon Yakobson
Messages: 3275 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
shawaj wrote on Fri, 04 August 2017 22:19
I am using like this
You need SUM, not LAG:
SQL> select ename,sal,sum(sal) over(order by ename) from t3;
ENAME SAL SUM(SAL)OVER(ORDERBYENAME)
-------------------- ---------- --------------------------
A 10 10
B 20 30
C 30 60
D 40 100
SQL>
SY.
|
|
|
|