test sql

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

declare @table table
(mark int, 
name varchar(10), 
cost int, 
salecategory int, 
costcategory int)

insert @table values(10, 'pete', 20, '9', '8')
insert @table values(14, 'pete', 20, '9', '7')
insert @table values(15, 'pete', 20, '5', '6')
insert @table values(10, 'pete', 56, '6','2')
insert @table values(15, 'John', 10, '7','3')
insert @table values(22, 'John', 10, '2','1')
insert @table values(20, 'John', 10, '1','1')

SELECT
*,
SUM(mark) OVER (PARTITION BY salecategory ORDER BY name ROWS UNBOUNDED PRECEDING) as test
from
@table
;

Enter Parameters

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