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

Can we use joins in subquery?

0 Answers  


What is sql in oracle?

0 Answers  


Why are indexes and views important to an organization?

0 Answers  


What is function and procedure in pl sql?

0 Answers  


The select into statement is most often used to create backup copies of tables or for archiving records?

0 Answers  






Is a foreign key always unique?

0 Answers  


How do I install microsoft sql?

0 Answers  


there are .......different types of serializability

1 Answers   Wipro,


Explain isolation levels. : Transact sql

0 Answers  


Hi am new to PLSQL & facing problems in writing code like in SP, Functions, so any one having some SP coding with in depth explanation please share with me my Email ID suvarnaatsuvarna@rediffmail.com Or taking tanning on this please do contact me

0 Answers  


Display the total debit counts, total credit counts, sum of total debits, sum of total credits from an employee's transaction table (a single table) containing the following columns. Transaction_number Transaction_amount Transaction_date Transaction_type --> tells if the amount is a credit or a debit. As the query alone is important, the table is left with specifying just the field's name. Pls help me with this query.

3 Answers   iNautix, Oracle,


What are different types of functions in sql?

0 Answers  


Categories