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



I have a table like this tblData (month int,Qty int) and i am inserting three rows in this table ..

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

I have a table like this tblData (month int,Qty int) and i am inserting three rows in this table ..

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

I have a table like this tblData (month int,Qty int) and i am inserting three rows in this table ..

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




I have a table like this tblData (month int,Qty int) and i am inserting three rows in this table ..

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



More MySQL Interview Questions

i made a table in sql server 2000 and in a column i want to add image path of a picture present in my hardisk... so using insert statement how will i insert the path of the image in the table??

1 Answers   WebTech,


What is the maximum length of a table name, database name, and fieldname in MySQL?

3 Answers   Accenture, TISL, Pioneer,


How many values can the SET function of MySQL take?

2 Answers   Creative Informatics,


about join

2 Answers  


What is Inner Joints and Outer Joints ? What is right outer joints,left outer joints,right inner joints , left inner joints ,

2 Answers   HP,






maximum size of a database in mysql?

2 Answers  


what is mySQL. Is there any specific qualification required to do this course ? What is the scope in India after doing mySQL

0 Answers  


Explain federated tables?

3 Answers   Tech Mahindra,


What are some good ideas regarding user security in MySQL?

2 Answers  


what is the main difference between myisam and innodb

2 Answers   Wipro,


Give the syntax of Grant and Revoke commands?

1 Answers  


What are the other commands to know the structure of table using MySQL commands except explain command?

2 Answers   SigmaTree,






Categories