Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 resta value from column to column

Author  Topic 

x_jhofran_x
Starting Member

1 Post

Posted - 2011-08-12 : 13:34:54
90 | 90-20=70 | 70-60=10 | 10-05=05
50 | 50-10=10 | 10-00=10 | 10-08=02
00 | 00-00=00 | 00-00=00 | 00-00=00
20 | 20-05=00 | 15-10=05 | 05-05=00


* first column is the initial value to subtract

* subtracting the other columns are according to the previous

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-08-12 : 14:01:21
If I understood your requirement correctly, probably the simplest (and perhaps the only) way is the dumbest way as in

SELECT
col1,
col1-col2,
col1-col2-col3
-- and so on
FROM
theTable;
Go to Top of Page
   

- Advertisement -