In reply to Ksharp.

Thanks for posting an SQL solution.