Fix syntax error in matrix query