php - Sum of column equals, A - B -


this may straight forward one. i'm playing around little app i'm trying create. i've got form users submit "buy_price" , "sell_price". trying work out if have made loss or profit. better have column within database works out "margin" i.e "margin coulmn = sell_price-buy_price" (and how this). or better within php.

thank in advance.

dan

edit: use database because store data , can view purchase history. want make section such "best trades" ones highest margin etc.

i absolutely not store calculated values in database simple - maintenance outweigh marginal gains in efficiency.

even without storing value, still have option on whether calculate value upon retrieval (with mysql) or php when rendering.

select buy_price, sell_price, (buy_price - sell_price) margin x 

sql aside, i'd still go calculating upon render php.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -