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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the difference between between and in operators in mysql?

505


What is mysql enterprise edition?

460


How do I run a query in mysql?

489


how to show all records starting with the letters 'sonia' and the phone number '9876543210' limit to records 1 through 5.

522


What is the maximum connection pool size?

513






Where’s database data actually stored?

524


Why we use mysql database?

489


How can you filter the duplicate data while retrieving records from the table?

478


What is the insert?

495


How to drop an existing view in mysql?

532


Consider you have the following three tables which have to be linked together.

501


How to give user privilages for a db. Login as root. Switch to the mysql db. Grant privs. Update privs.

485


Consider you have a composite index of three columns. Now, you have to provide the value of two columns in the where clause of a select query. Do you think index can be used for the operation?

506


How do I install mysql?

468


How do I connect to a database in mysql workbench?

552