Jump to content

Finding the diference between two values


seran128

Recommended Posts

I have a table that looks like this

tbl_product

ID        Cost
1          5.23
2          3.76
7          25.22


now I want to run a query that returns the value of the difference between two product id's

like

psudeo code
finalcost = (select cost from tbl_products where id = '1') - (select cost from tbl_products where id = '2')

in this case finalcost should be 1.47

Is there a way to do this in one SQL statment
Link to comment
https://forums.phpfreaks.com/topic/25455-finding-the-diference-between-two-values/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.