Regarding sum of a column
-
Hi , im using two tables , tbl1,tbl2 . im multiplying tb1.column1 ,tbl2.column and displaying as result . i want to display sum(column1.column2) as total (another column). can any body tell me the query for this , Thank u. C.S.n
I feel I have the wrong handle on your problem but... If you want the additional of col1 + col2 then it is the same method as the multiply If you are after the sum of all the records preceding the current record then you need to look into running totals (depends on your DB) if you want the sum of the 2 cols included in the result set you need to do the query 2 times, 1 to get the total into a var and the seconed to include it in your result set You really need to define your problem a little clearer. Remember we have not gone through the process of getting where you are stuck and do not have the code in front of us.
Never underestimate the power of human stupidity RAH
-
Hi , im using two tables , tbl1,tbl2 . im multiplying tb1.column1 ,tbl2.column and displaying as result . i want to display sum(column1.column2) as total (another column). can any body tell me the query for this , Thank u. C.S.n
Depending on whether you are trying to just add the two columns together, or add the sum of the columns together, you could either do:
select tbl1.column1 + tbl2.column as summation
or
select sum(tbl.column1 + tbl2.column) as total
Deja View - the feeling that you've seen this post before.
-
Hi , im using two tables , tbl1,tbl2 . im multiplying tb1.column1 ,tbl2.column and displaying as result . i want to display sum(column1.column2) as total (another column). can any body tell me the query for this , Thank u. C.S.n
mrsuman wrote:
im using two tables , tbl1,tbl2 . im multiplying tb1.column1 ,tbl2.column and displaying as result . i want to display sum(column1.column2) as total (another column). can any body tell me the query for this ,
Is this what you are looking for:
select tbl1.column1,tbl2.column2,tbl1.column1*tbl2.column2 as Result, sum(tb1.column1*tbl2.column2) as Total
This query will have the Total column as the same value for all the rows. -
mrsuman wrote:
im using two tables , tbl1,tbl2 . im multiplying tb1.column1 ,tbl2.column and displaying as result . i want to display sum(column1.column2) as total (another column). can any body tell me the query for this ,
Is this what you are looking for:
select tbl1.column1,tbl2.column2,tbl1.column1*tbl2.column2 as Result, sum(tb1.column1*tbl2.column2) as Total
This query will have the Total column as the same value for all the rows.Hi, Sorry for late reply . here im having price of seat in one table and no. of seats in another table. i want to get result(Price * No. Of Seats ) as amount to pay as one cloumn and total of these values as another column. i think now u can understand my problem .. can u tell me the query how can i do this . thanks .
-
I feel I have the wrong handle on your problem but... If you want the additional of col1 + col2 then it is the same method as the multiply If you are after the sum of all the records preceding the current record then you need to look into running totals (depends on your DB) if you want the sum of the 2 cols included in the result set you need to do the query 2 times, 1 to get the total into a var and the seconed to include it in your result set You really need to define your problem a little clearer. Remember we have not gone through the process of getting where you are stuck and do not have the code in front of us.
Never underestimate the power of human stupidity RAH
Hi , i will explain where i stuck .. i'm having two tables transaction and pricing . in transaction table i'm having number of seats column and price/seat in pricing . here i want a column which displays (no. of seats * price/ seat ) and sum of all these rows as next row or separate column.i'm getting(no. of seats * price/seat) using join but im not getting how to do sum of all these rows . can u tell me this pls .. thanks csn
-
mrsuman wrote:
im using two tables , tbl1,tbl2 . im multiplying tb1.column1 ,tbl2.column and displaying as result . i want to display sum(column1.column2) as total (another column). can any body tell me the query for this ,
Is this what you are looking for:
select tbl1.column1,tbl2.column2,tbl1.column1*tbl2.column2 as Result, sum(tb1.column1*tbl2.column2) as Total
This query will have the Total column as the same value for all the rows.i will explain where i stuck .. i'm having two tables transaction and pricing . in transaction table i'm having number of seats column and price/seat in pricing . here i want a column which displays (no. of seats * price/ seat ) and sum of all these rows as next row or separate column.i'm getting(no. of seats * price/seat) using join but im not getting how to do sum of all these rows . can u tell me this pls .. thanks csn
-
i will explain where i stuck .. i'm having two tables transaction and pricing . in transaction table i'm having number of seats column and price/seat in pricing . here i want a column which displays (no. of seats * price/ seat ) and sum of all these rows as next row or separate column.i'm getting(no. of seats * price/seat) using join but im not getting how to do sum of all these rows . can u tell me this pls .. thanks csn
Can you give an example output you want from this query?
-
Can you give an example output you want from this query?
-
Thanks for u r reply .. ex : result ------ 200 350 500 400 250 in next row or separate column i want sum of these rows .
If having it in the same row is Ok, then my earlier query should work for you (providing of course that you specify the correct join condition).