I have a table like this tblData (month int,Qty int)
and i am inserting three rows in this table
1.tblData Values (1,100)
2.tblData Values (2,200)
3.tblData Values (3,300)
The Result I want is the Running total of the field Qty
that is 1 100 100
2 200 300
3 300 600
What is the Query for that ?
Answers were Sorted based on User's Feedback
Answer / anurag misra
select a.month,a.Qty,sum(b.Qty) as total
from tblData a cross join tblData b
where b.month<=a.month
group by a.month,a.Qty
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / bibinsami3
i Will give 3 pts to them who find the answer with out
reffering any Documets.. :)
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / sandhirasegaran
SELECT tbl1.month,tbl1.Qty,( SELECT SUM(tbl2.Qty) FROM
tblData AS tbl2 WHERE tbl1.month >= tbl2.month ) FROM
tblData AS tbl1
| Is This Answer Correct ? | 1 Yes | 0 No |
using primary can we relate two table, with out foreign key?
What is ACID?
What are the indexes in mysql?
Does uninstalling mysql delete database?
Can I copy mysql data directory?
Is mysql a distributed database?
Can we store files in mysql?
What is DDL in MySQL?
Differentiate CHAR_LENGTH and LENGTH?
Why do gaps in sequences occur?
can you tell the order of sql select statement? : Mysql dba
What is the difference between now() and current_date()?
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)