Help with complex SQL

Original text of this message