• Wayne West (4/21/2015)


    Dwain, that first code worked perfect, the second one only has D/N/P/Y appearing for district 000, which may or may not work live. Since the first one does work the way that I need, that's the one that I'll use. I'd never used that format of a Select, most of my time has previously been spent in a DBA role. This greatly improves the fairly ugly code that I was dealing with. Much thanks!

    Strange that the second solution didn't work. Thought I'd nailed it. But then I didn't have access to the underlying data to be sure.

    In any event, glad I provided something that could help.

    Edit: I realized that it is probably the second LEFT OUTER JOIN in my second solution that is the reason it doesn't work for you. Because there's no district 000 in that table.


    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