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 ?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

I've looked but can't find a MySQL equivalent for MS SQL's xp_cmdshell. I have 7z files that I want to unzip and load into MySQL. I'm trying to write a sp to do the unzip, but I can't find a way to do that. Can anyone provide an example of a similar process in Windows? TIA.

3444


What is sql vs mysql?

528


How do I flush privileges in mysql?

499


Is mysqli faster than mysql?

491


What is mysqli procedural?

528






What command is used to delete the data from the table without deleting the table structure?

462


How to create a test table in your mysql server?

503


What is a join? Explain the different types of mysql joins.

701


How to update a root password.

538


Is mysql connect deprecated?

495


What is the maximum number of columns per table?

487


What is mysql and why it is used?

565


How do I assign a variable in mysql?

481


what is the default port for mysql server? : Mysql dba

561


What is delimiter $$?

502