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

How do you change a password for an existing user via mysqladmin?

2 Answers  


If you specify the data type as DECIMAL (5,2), what?s the range of values that can go in this table?

2 Answers  


How can we know the number of days between two given dates using MySQL?

2 Answers   Webworks, Base2 Infotech,


What is the difference between SQL and SQL Server?

3 Answers   HCL, Cognizant,


how we can use more then one primary key in Single Table

9 Answers   Systematix,






How can we change the name and data type of a column of a table?

9 Answers   Google,


Explain the difference between FLOAT, DOUBLE and REAL.

14 Answers   Yahoo,


A company wants to store their invoices in a database. They already have their customers and articles in that database. Both customer and article are each identified by an unique integer value. Please create the SQL statements for creating the necessary table(s) for storing the invoices in a MySQL database. An invoice should hold information like invoice number, customer, date, article(s) and quantity etc.

1 Answers  


Explain MySQL locks?

1 Answers  


Use mysqldump to create a copy of the database?

2 Answers  


how to find max salary from the database

3 Answers  


maximum size of a database in mysql?

2 Answers  






Categories