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
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 |
Answer / vinay
Select c1,sum(c2) over (order by c1) as C3 from T1
| Is This Answer Correct ? | 13 Yes | 2 No |
What is left join in sql?
Wat is SGA ?
What is Difference Between Unique and Primary Key Constraints?
When to use inner join and left join?
Which is faster count (*) or count 1?
Explain the insert into statements in sql?
how to see the oracle 9i/10g table in pc? or In my pc where the table is saved and how to see?
What is an index in sql with example?
what is subquery? : Sql dba
How do I kill a query in postgresql?
What is dml with example?
What is meant by cursor in sql?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)