Fix filter sql condition