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

select a.month,a.quantity,sum(b.quantity) as total from qunt
a cross join qunt b
where b.month<=a.month
group by a.month,a.quantity
order by month

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is foreign key indexed mysql?

645


What is the limit of mysql database?

677


What port is mysql running on?

658


What is the difference between having and where clause in mysql? Explain

735


What are federated tables?

825


What is blob storage?

686


How do I change mysql password?

673


What is mysqli procedural?

699


What does mysqli_fetch_assoc do?

664


How do I find the database name in mysql?

694


What's the difference between mysql and sql server?

676


Does mysql use sql?

668


How can you take the backup and restore a mysql database using php?

672


What is mysql installer?

685


What is longblob in mysql?

709