Filling in the inbetweeners

  • Hi All,

    I hope someone can help me come up with an efficient solution for this problem.

    Background info:

    table 1 columns are

    location, startdate, enddate, status

    test data:

    loc1 | 2010-07-21 | 2010-10-13 | Good

    loc2 | 2010-06-09 | 2010-09-29 | Neutral

    loc1 | 2010-10-14 | 2010-12-12 | Neutral

    loc3 | 2010-03-12 | 2010-05-02 | Bad

    I have written a stored procedure that, when run, will generate results based on the above test data (please see attached document: current output section). Currently, I simply update the column corresponding to that locations startdate's month and year.

    Lets get into a little more detail:

    As you can see from the current output (please see attachment), the table has columns showing the months of the years which are generated dynamically using the min(startdate) and max(startdate) of the test data, regardless whether or not there is data for those columns at those locations. If you look at location 1, its first status exists from July to October where it changes to neutral going forward.

    Desired outcome:

    Please see attached document: desired output section.

    I hope this gives you a pretty good idea of what I am trying to achieve.

    Many thanks in advance.

    taybre

    HTH :-):-)
    taybre

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • You may have noticed that there's no response yet.

    One possible reason is the way the question is posted: some of us simply will skip a post if we have to open a separate document to see what the issue really is. We'd also like to se some ready to use sample data so we immediately can start working on a solution rather than trying to collect all the information needed.

    I recommend you to take a look at the first article referenced in my signature on how to post sample data and to describe the problem you're struggling with.

    I'm sure once the question is in a more usable form, you'll find several people trying to help you.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Lutzm,

    Thanks for the feedback and I will be redo the question into a friendly format. Unfortunately I can only do this tomorrow. Should I rather edit the first post or repost the topic?

    Regards,

    Taybre

    HTH :-):-)
    taybre

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • I'd say add another post to this thread. To pen another thread regarding the same issue doesn't make that much sense and if you'd simply edit your first post folks like me who subscribed to this thread won't get notified automatically.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

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

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