• kishorreddy.yuva (3/26/2014)


    I have a table with five columns as

    ID Join_Date Join_Qtr End_Date End_Qtr

    1 2014-01-12 2014Q1 2015-05-15 2015Q2

    2 2012-05-01 2014Q2 2017-01-01 2016Q1

    i want to populate a column which is based on difference between (Col2 'Join_Date' - Col4 'End_Date' ) or (col3 'Join_Qtr' - col5 'End_Qtr') result as

    id output

    1 2014Q1, 2014Q2, 2014Q3, 2014Q4, 2015Q1, 2015Q2

    2 2014Q2, 2014Q3, 2014Q4, 2015Q1, 2015Q2,2015Q3, 2015Q4, 2016Q1

    How can i do this ,

    Please suggest me .

    Thanks In advance.

    kkr

    Hi and welcome to the forums. I have an idea of what you want but your post is too unclear. I don't fully understand what the output comes from. It would help a lot if you could post ddl and sample in a consumable format. Please take a few minutes and read the first article referenced in my signature for best practices when posting questions.

    _______________________________________________________________

    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/