diff --git a/store/sqlstore/agent_store.go b/store/sqlstore/agent_store.go index 2a2d6b02..edcf0bd1 100644 --- a/store/sqlstore/agent_store.go +++ b/store/sqlstore/agent_store.go @@ -200,8 +200,8 @@ FROM call_center.cc_agent a_1 WHERE (q_1.team_id IS NULL OR a_1.team_id = q_1.team_id) and q_1.enabled and x.xxx && array [a_1.id] - and coalesce((q_1.payload->'min_online_agents')::int, 0) > 0 - and array_length(x.xxx, 1) <= (q_1.payload->'min_online_agents')::int + and GREATEST(coalesce((q_1.payload->'min_online_agents')::int, 0), 0) > 0 + and array_length(x.xxx, 1) <= GREATEST((q_1.payload->'min_online_agents')::int, 0) and a_1.id = :AgentId::int and a_1.domain_id = :DomainId::int8)`, map[string]interface{}{ "AgentId": agentId,