Sum the array times n, except the last

0

Please login or register to vote for this query.

(click on this box to dismiss)

Philosophy Meta

Q&A about the site for those interested in the study of the fundamental nature of knowledge, reality, and existence

DECLARE @ INT=10
CREATE table #t(a int,i int identity)
INSERT #t values(3),(1),(4),(1),(5)

--SELECT sum(a*@-i/@@rowcount*a*~-@)FROM #t
SELECT 
--sum((i/@@rowcount*~-@+1)*a)
(i/@@rowcount*~-@+1)
FROM #t

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results