i have a table like this. i want to output like this
c1 c2 c1 c2

1 10 1 10
2 20 2 30
3 30 3 60
4 40 4 100
5 5 5 105

c1 and c2 are columns in a table .i want output like this

c2 values are 10,10+20,10+20+30,10+20+30+40.10+20+30+40+5.

write a sql query.pls help this
i want urgent.

Answers were Sorted based on User's Feedback



i have a table like this. i want to output like this c1 c2 c1 c..

Answer / prativa mishra

select t.c1,
(SELECT SUM(x.c2)
FROM table_name x
where x.c1 <= t.c1) as c2
from new table_name


or

select c1,
SUM(SUM(c2)) OVER
(ORDER BY c1 ROWS BETWEEN UNBOUNDED PRECEDING AND
CURRENT ROW)
AS C2
from table_name
group by c1

Is This Answer Correct ?    17 Yes 2 No

i have a table like this. i want to output like this c1 c2 c1 c..

Answer / vinay

Select c1,sum(c2) over (order by c1) as C3 from T1

Is This Answer Correct ?    13 Yes 2 No

Post New Answer

More SQL PLSQL Interview Questions

How to use sql*plus built-in timers?

0 Answers  


How you improve the performance of sql*loader? : aql loader

0 Answers  


Can we use ddl commands in pl sql?

0 Answers  


Question: Below is the table city gender name delhi male a delhi female b mumbai male c mumbai female d delhi male e I want the o/p as follows: male female delhi 2 1 mumbai 1 1 Please help me in writing the query that can yield the o/p mentioned above?

2 Answers  


how to retrieve the top 3 salaries of the table using rownum

31 Answers   Oracle,






Write a pl/sql script to display the following series of numbers: 99,96,93……9,6,3?

1 Answers  


how to load data files into tables with 'mysqlimport'? : Sql dba

0 Answers  


What is trigger point?

0 Answers  


What is pls integer?

0 Answers  


What are the types of subqueries?

0 Answers  


how to retrieve last tree records from table? select *from emp where rownum > (select count(*)-3 from emp); i am using this query to get last three records from table but its not giving any output, so please tell me what is the error in this query.

16 Answers  


write a query that returns first characters of each word in Oracel/Sql pl sql

5 Answers  


Categories