write sql query following source are
EmpID, Salary
101 1000
102 2000
103 3000
I want the output format like following
empid,sal,composite_sal
101 1000 1000
102 2000 3000
103 3000 6000
Answers were Sorted based on User's Feedback
Answer / bijaylaxmi sahoo
write sql query following source are
table name-emp_det
EmpID, Salary
101 1000
102 2000
103 3000
answer-
select t.empid,t.sal,(select sum(x.sal) from emp_det x
where x.empid<=t.empid) as com_sal
from emp_det t;
output-
empid,sal,composite_sal
101 1000 1000
102 2000 3000
103 3000 6000
| Is This Answer Correct ? | 9 Yes | 1 No |
Answer / mukesh
select empid,
salary,
sum(salary) over(order by empid rows unbounded
preceding) composite_sal from source
| Is This Answer Correct ? | 3 Yes | 0 No |
select empid,
salary,
sum(salary) over(order by empid rows unbounded
preceding) composite_sal from (select 101 EmpID, 1000
Salary
from dual
union all
select 102, 2000
from dual
union all
select 103, 3000
from dual
union all
select 110, 5000 from dual)
| Is This Answer Correct ? | 0 Yes | 1 No |
what is a Nested Loop join?
Define the terms primary key foreign key and also the difference between primary and the unique key
I'm doing my final year and i ve planned to do an oracle certification , is this the rit tim nd wat's the future scope??
How to create a table in a specific tablespace?
How to see free space of each tablespace?
What is a Data Segment ?
I want a table like, no name address addr1 addr2 So i want columns like addr1,addr2 under address column. Can one please answer me. Advance Thanks.
What does ROLLBACK do ?
How to execute a stored procedure in oracle?
What are the factors causing the reparsing of SQL statements in SGA?
How to update rows in table, suppose i have lacks of rows in table how to update total table with update statement. Can u please any one answer this question with update statement.
How to write date and time literals in oracle?