move condition into sql statement