How to find difference between two columns data?

vision picture vision · Oct 2, 2013 · Viewed 169k times · Source

I have a temp table with two columns of integer data i want to find the difference between two columns in 3rd column.

#TEMP1

Present   previous
59           88
75           75
45           45
77           88
09           08

#temp2

Difference
 29
 0
 0
 11 
 -1

Is this possible ??

Answer

Mujah Maskey picture Mujah Maskey · Oct 2, 2013
select previous, Present, previous-Present as Difference from tablename

or

select previous, Present, previous-Present as Difference from #TEMP1