adding preyear column besides year column

  • Hi, I need your expertise on this issue. Basically the reason to do this is to calculate YTD values.

    For example, I have the following period table

    year period quarter

    --------------------------

    2011 01 Q1

    2011 02 Q1

    2011 03 Q1

    Based on the example above, I intend to get the following result set:

    year period quarter preyear

    --------------------------

    2011 01 Q1 2010

    2011 02 Q1 2010

    2011 03 Q1 2010

    Any help you can provide with be greatly appreciated.

  • Just add the following in the select list

    (YEAR - 1) AS PreYear

  • In case you require it in the table structure, you can go for computed columns... more details from MSDN

    http://msdn.microsoft.com/en-us/library/ms191250.aspx

    [font="Times New Roman"]For better assistance in answering your questions
    Click Here[/url][/font]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply