• Nevyn (2/10/2014)


    I also tweaked to Nevyn's solution so that it will produce the correct answer (Nevyn's solution is very good but I think it should include WHERE rownum=1.)

    Yep. Was trying to get the answer in before lunch was over and I had to run to a meeting, and forgot that rather important detail.

    Been there:hehe: still a very good solution!

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001