• 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.