sql comparison and flag

Original text of this message