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

Running Sum

$
0
0

Hi All,

DECLARE @example TABLE(ID INT, Amount float)
INSERT INTO @example VALUES(1,100), (2,500), (3,50), (4,200)

select * from @example

DECLARE @Target Float = 600

Now, I need top records where Sum(Amount) = @Target, this target may vary.

Can some please give me a tsql query for this.

thanks!



Viewing all articles
Browse latest Browse all 23857

Trending Articles



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