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 |
How to upsert (update or insert into a table)?
1) What is ONE_SIZE_FITS_ALL approach? 2) Explain the Common & Variable Header of DATA FILE? 3) What are the Drawbacks to using OMF DB? and the Advantages? 4) List out the Advantages of Undo T.spaces over the Undo SEGMENT? 5) Difference between the Temporary tablespace with TEMPFILE and the Tablespace with TEMPORARY Keyword? 6) What are the situation extents are freeing for reuse.
What is program global area (pga) in oracle?
What is dual table oracle?
How to insert a new row into a table in oracle?
How can you use check constraints for self referential integrity?
How to use "while" statements in oracle?
What is TNS File
What happens to indexes if you drop a table?
Difference between an implicit & an explicit cursor.?
What is difference between truncate and delete?
What are the components of Physical database structure of Oracle Database?