• Seems like a semi strange requirement but certainly not to bad. Notice how I posted consumable ddl and sample data? This is something you should do in the future.

    Here are a couple of different ways...I am sure there are plenty of others.

    create table #Something

    (

    Years int,

    SomeValue int

    )

    insert #Something(Years, SomeValue)

    Values

    (2000, 2)

    ,(2001, 4)

    ,(2002, 5)

    ,(2003, 3)

    ,(2004, 2)

    select SUM(SomeValue) as SumOfAll, (select SUM(SomeValue) from #Something where Years <= 2002) as SumTo2002

    from #Something

    select SUM(SomeValue) as SumOfAll, x.Sumto2002

    from #Something

    cross apply (select SUM(SomeValue) as Sumto2002 from #Something where Years <= 2002)x

    group by x.Sumto2002

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/