Home Forums SQL Server 2012 SQL Server 2012 - T-SQL Querying a Supersession Two Column Table with Multiple Supersessions in both Columns RE: Querying a Supersession Two Column Table with Multiple Supersessions in both Columns

  • I'm just guessing here because I don't have much additional time to look deeper, but this probably has to do with the fact you have no "supersession date" on your Supersessions table (recall I mentioned this earlier).

    If you look at the code I provided (the last query), you see I'm jumping through quite a few hoops to try and get a reasonable sort order that places earlier part numbers before later ones. What I did there is far from perfect and probably leads you to situations like this. In effect, there is no way to determine the order that part numbers get retired/replaced. Ultimately I think you'll need that to get a good list of supersession parts in an appropriate sequence.


    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