Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subtracting Current row from Previous

Status
Not open for further replies.

mistermci

Technical User
Sep 2, 2006
2
US
I am trying to create a query that will subtract the current row of a column from the previous row, and if the value is negative, just return the value of the current column in the result column. For example, if I had the table below, here are the results I would like to see:

Key value REQUIRED RESULT
1 12 12
2 21 9
3 3 3
4 1 1
5 67 66

I have no idea how to do this, thanks for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top