Subctracting rows and adding columns after search result Programming Web Development by tonyfonseca I have the following code to search the stores by name and and order by transaction date by Asc which works perfect. My questions is how to performe a subtraction by row (checkamount-redeposited-replacement-paidcash = balance) and totalize by columns (total checkamount, total redeposited, total replacement, total paidcash and total balance) by … Re: Subctracting rows and adding columns after search result Programming Web Development by LastMitch **@tonyfonseca** >My questions is how to performe a subtraction by row (checkamount-redeposited-replacement-paidcash = balance) and totalize by columns (total checkamount, total redeposited, total replacement, total paidcash and total balance) by store name and by all stores using a drop down combo box. This is surreal. The question is you … Re: Subctracting rows and adding columns after search result Programming Web Development by tonyfonseca Please, I just need to know how to subtract the rows horizontal and how to add the columns vertically after searching an item.The searching function is already working i only need to subtract the rows and sum the columns by store name and between start and end date. Your help is very appreciated. Thanks Re: Subctracting rows and adding columns after search result Programming Web Development by LastMitch **@tonyfonseca** >Please, I just need to know how to subtract the rows horizontal and how to add the columns vertically after searching an item.The searching function is already working i only need to subtract the rows and sum the columns by store name and between start and end date.Your help is very appreciated. Thanks You didn't provide the … Re: Subctracting rows and adding columns after search result Programming Web Development by diafol Could you please state which columns you need to sum. Your description is a bit vague. Also when you say subtract rows, do you mean filter the dataset to only return certain rows as in using the WHERE (or HAVING) clause or like your first entry - the calculated field - balance? If the latter, I can't see why a calculated field is actually, … Re: Subctracting rows and adding columns after search result Programming Web Development by tonyfonseca $query = "SELECT * FROM books Sum(checkamount - redeposited - replacement - paidcash) AS total, sum(checkamount), sum(redeposited), sum(replacement), sum(paidcash), sum(balance) WHERE transactiondate BETWEEN DATE_FORMAT(transactiondate,'%".$small."') AND DATE_FORMAT(transactiondate, '%".($large)."') AND storename LIKE … Re: Subctracting rows and adding columns after search result Programming Web Development by LastMitch **@tonyfonseca** >I think here is where i have to fix the code. First i want to calculate the balance for each row like (balance = checkamount-redeposited-replacement-paidcash) then i want to sum all those columns at the end of table. I don't understand your query at all. But the image does show the table. The image looks more like a Excel … Re: Subctracting rows and adding columns after search result Programming Web Development by diafol OK, I see. SIngle calculated field and just a row of totals. Possibly you could use 'WITH ROLLUP' syntax. I'll have to think about that. Re: Subctracting rows and adding columns after search result Programming Web Development by tonyfonseca Please i appreciate if you could help me with that. I did a lot of researches and i couldn’t find anything like that. Thanks for your help Re: Subctracting rows and adding columns after search result Programming Web Development by LastMitch **@tonyfonseca** >Please i appreciate if you could help me with that. I did a lot of researches and i couldn’t find anything like that. I'm not sure what are you asking? I gave you some examples on how to approached it. **Diafol** also gave you some instructions on how to approach this differently. Here is a couple of links of what **Diafol**… Re: Subctracting rows and adding columns after search result Programming Web Development by diafol If you could post an sql dump file of your table, that would enable us to fiddle with it. Trying to build one in order to test is a pain. Re: Subctracting rows and adding columns after search result Programming Web Development by tonyfonseca Thanks for your help. I am not geting paid for this work. This is a program that i am doing to facilitate my job, because i use excel for that. If i use a program like that my job will be easier. Attached is a snapshot of the tables. Thanks again for your help. [![![![Click Here](/attachments/large/2/stores_table.jpg &… Re: Subctracting rows and adding columns after search result Programming Web Development by LastMitch **@tonyfonseca** When **diafol** mention this: > If you could post an sql dump file of your table, that would enable us to fiddle with it. Trying to build one in order to test is a pain. He meant for you to do this: http://www.java2s.com/Tutorial/MySQL/0520__MySQL-Utilities/SelectintoaDUMPFILE.htm or try this: http://www.tutorialspoint.com… Re: Subctracting rows and adding columns after search result Programming Web Development by tonyfonseca Sorry i didn't understand you at the begining how to dump the files. Here i have a copy of the files. Thank you very much for your help. -- phpMyAdmin SQL Dump -- version 3.3.9 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Oct 25, 2012 at 12:19 AM -- Server version: 5.5.8 -- … Re: Subctracting rows and adding columns after search result Programming Web Development by tonyfonseca Hi everybody thanks for your precious help but i have got the code working already. Somebody helped me to fix it. As soon as i have a chance i will post it in case somebody needs it Thanks