Try changing the query to use AND WITH instead of AND WHEN. Keep in mind that uniQuery differs from standard SQL statements.