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

What happens when the column is set to AUTO INCREMENT and if you reach maximum value in the table?

515


What is row?

551


Why does mysql have so many connections?

484


How do I start and stop mysql server?

462


In how many ways we can retrieve data in the result set of mysql using php?

603






How do I install and use mysql?

472


write a command to view the content of the table

484


How to insert html code into mysql database using php?

519


How to print message in mysql trigger?

986


What are mysql data types?

511


What are the purposes of using enum and set data types?

500


Can you tell how to find the number of rows in a resultset using php?

457


Is blocked because of many connection errors unblock with mysqladmin flush hosts?

485


List some comparisons operators used in mysql?

517


How do I run mysql on a mac?

465