Correct check for status != 'archived' and improve query using JOIN