• rlindstrom 38273 (11/5/2013)


    Since I'm new to this maybe another shot at explaining.

    There are no empty records in the coitem_log table - every time a line item on a order is changed an entry is created. When I run this wide open I get my list of all product codes and items that match each product code - NULLS are what I'm expecting if a specific product code didn't have activity for any of its corresponding items.

    Most months there are some product codes that DON'T have corresponding items on a order but each month I need a complete list of all the product codes and activity for any items that match it's corresponding product code.

    thanks for the suggestions thus far - hope this helps.

    I believe that I understand what you are saying. For example, if you date filtering criteria spans 2 months, you'd like any product code listed with a NULL activity date to show once or twice depending on whether it was missing from either or both of those months. Is that accurate?

    This can be done but it is easier to provide you a working example if you were to help us out with some DDL, consumable sample data and expected results.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St