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



write sql query following source are EmpID, Salary 101 1000 102 2000 103 3000 ..

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

write sql query following source are EmpID, Salary 101 1000 102 2000 103 3000 ..

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

write sql query following source are EmpID, Salary 101 1000 102 2000 103 3000 ..

Answer / niru

select empid,sal,sal+lead(nvl(sal,0) from emp_det

Is This Answer Correct ?    0 Yes 0 No

write sql query following source are EmpID, Salary 101 1000 102 2000 103 3000 ..

Answer / farrukh shaikh

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

Post New Answer

More Oracle General Interview Questions

What are the differences between char and nchar in oracle?

0 Answers  


What are the different approaches used by Optimizer in choosing an execution plan ?

2 Answers  


For a field in a repeating frame, can the source come from the column which does not exist in the data group which forms the base for the frame ?

0 Answers   Oracle,


Table1- have two column filename data AFGDFD-20112011 hi how r u bsdasd-23042011 name shoud be in bold Now i want output like filename data AFGDFD hi how r u bsdasd name shoud be in bold Kindly answer this

2 Answers   HCL,


How to upsert (update or insert into a table)?

0 Answers  






How to put more than 1000 values into an oracle in clause?

0 Answers  


Is there a function to split a string in plsql?

0 Answers  


what is primary key?

9 Answers  


what is the syntax of SELECT command?

6 Answers  


How to drop a stored procedure in oracle?

0 Answers  


how can get like this result table A col1 col2 --- ----- a A b B C C .. .. .. ... .. ... wants result like for a single column col1 ------ a,b,c,........n of data and another is col1 ------- A B C D ........ a b b d ........

2 Answers   TCS,


Is it possible to enter only time value into a column of a table in sql?

2 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)