Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Subtract and Sum in SQL

$
0
0

declare @a float
set @a = 100
select @a

create table  #t
(id int,
 colA int,
 colB INT
)
insert into #t
select 1,2,4
union
select 2,4,3
union
select 3,3,2
union
select 4,5,4
union
select 5,8,1

SELECT * FROM #t


--need to create new column, in that in first row veriable @a - colA + ColB,
--starting from second row  LAST ROW OF NEW COLUMN - colA + ColB

--second row example (fitst row of new column - colA + colB)
--third row example (second row of new comumn - colA + colB)

using 2008 R2

Thank You so Much



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>