Refactor some sql queries

Removed some unnecessary where clauses from email queries.