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

Print 3 highest salary

9 Answers  


Please suggest me any course and institute which provide training on the below skills. • Knowledge of data extraction concepts and tools • QMF (query management facility)queries • Experience and expertise in QMF queries • Excellent ability to write, read, and interpret QMF queries against the Source Data Warehouse base level (daily and monthly) and month-end affinity comp tables • RDBMS & ER • Knowledge of Relational Databases (RDBMS) and Entity Relationship (ER) Diagrams • SOURCE Data Warehouse • Experience and expertise in Source Data Warehouse or data warehouses on the mainframe. • MS SQL Server • Experience in MS SQL Server • Excellent skill in writing/interpreting SQL queries and running Data Transformation Services (DTS) or open query packages. • Knowledge of writing/interpreting Visual Basic code.

1 Answers  


Can you save your connection settings to a conf file?

1 Answers  


Explain Normalization concept?

2 Answers   Inuva,


What?s the difference between PRIMARY KEY and UNIQUE in MyISAM?

4 Answers   Wipro, CSS, Aufait,






HOW TO FIND display the total number of weeks in the year of 1998 IN EMP TABLE

0 Answers  


What is diff b/w MYISAM and INNODB storage engine. and also define the benifits and drawbacks of both storage engine

1 Answers  


What is difference b/w composit key n primary key and forigion key?

4 Answers  


maximum size of a database in mysql?

2 Answers  


What is the difference between a Table and a View?

3 Answers  


What is the use of indexing table?

2 Answers  


What is Database?

2 Answers  






Categories