• born2achieve (2/14/2014)


    Hi Sean,

    Thanks for your reply.

    If the value is null then get the column form the pivot which is date and get the "daysinlate" data from table compaany based on the date and add the "daysinlate" data to the date colun of the pivot and display instead of null value.

    ex :

    on 2013-08-12 the value should be as "2013-08-27" = (2013-08-12 + 15 days)

    select daysinlate from company which is 15 so add 15 days of column(2013-08-12 + 15) which is 2013-08-27 on the row.

    am i explaining clear?

    So if there is no value you want to instead count the number of days since there was a value? I don't understand what you want for output. It seems you want a value in the 2013-08-27 column? What value would it be? And it shows up in that column because that is the value of daysinlate? What happens if the calculation takes you past the end of reported data?

    _______________________________________________________________

    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/