agregado
Consulte uma tabela usando uma função agregada, incluindo SUM, COUNT, MIN, MAX, LAST e AVG.
Campos de entrada
Qualquer elemento da tabela de destino. Além disso, uma ou mais das funções agregadas (SUM, COUNT, MIN, MAX, LAST e AVG).
Uma cláusula GROUP BY e HAVING também podem ser adicionadas.
Campos de saída
Um elemento agregadoResponse que encapsula todos os valores de campos do registro recuperado.
Amostra de mensagens SOAP
Solicitação SOAP de amostra usando a função agregada COUNT.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:m="http://www.service-now.com"
xmlns:tns="http://www.service-now.com/map"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<aggregate>
<COUNT>number</COUNT>
<active>true</active>
</aggregate>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>A resposta resultante de uma chamada de função agregada COUNT é semelhante a esta:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:m="http://www.service-now.com"
xmlns:tns="http://www.service-now.com/map"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<aggregateResponse>
<aggregateResult>
<avg>2.7200</avg>
</aggregateResult>
</aggregateResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>Amostra de solicitação SOAP usando a função agregada do AVG com uma cláusula GROUP BY.
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:m="http://www.service-now.com"
xmlns:tns="http://www.service-now.com/map"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<aggregate xmlns="http://www.service-now.com">
<GROUP_BY>category</GROUP_BY>
<active>true</active>
<AVG>severity</AVG>
</aggregate>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>A resposta resultante de uma chamada de função agregada do AVG com uma cláusula GROUP BY é semelhante a esta:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:m="http://www.service-now.com"
xmlns:tns="http://www.service-now.com/map"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<aggregateResponse>
<aggregateResult>
<avg>1.0000</avg>
<category>database</category>
</aggregateResult>
<aggregateResult>
<avg>3.0000</avg>
<category>hardware</category>
</aggregateResult>
<aggregateResult>
<avg>3.0000</avg>
<category>inquiry</category>
</aggregateResult>
<aggregateResult>
<avg>2.0000</avg>
<category>network</category>
</aggregateResult>
<aggregateResult>
<avg>2.6923</avg>
<category>software</category>
</aggregateResult>
</aggregateResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Solicitação SOAP de amostra usando uma consulta codificada para filtrar o agregado:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:m="http://www.service-now.com"
xmlns:tns="http://www.service-now.com/map"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<aggregate>
<COUNT>number</COUNT>
<active>true</active>
<__encoded_query>number=INC0000001^ORnumber=INC0000002</__encoded_query>
</aggregate>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>Solicitação agregada de amostra usando HAVING para restringir os resultados.
HAVING usa quatro campos. Cada campo é delimitado por "^": o tipo agregado, o campo do agregado, o tipo de operação e o valor a ser comparado.
Mais de um HAVING pode ser adicionado à solicitação, portanto, você pode usar expressões HAVING, mas não há suporte para OR.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:m="http://www.service-now.com"
xmlns:tns="http://www.service-now.com/map"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<aggregate>
<COUNT>sys_id</COUNT>
<GROUP_BY>internal_type</GROUP_BY>
<HAVING>COUNT^*^>^10</HAVING>
<HAVING>COUNT^*^<^20</HAVING>
<COUNT>sys_id</COUNT>
<active>true</active>
</aggregate>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>