GlideAggregate - 범위 지정됨
GlideAggregate API를 사용하면 데이터베이스 집계 쿼리를 만들 수 있습니다.
GlideAggregate 클래스는 GlideRecord 클래스의 확장이며 데이터베이스 집계(AVG, COUNT, GROUP_CONCAT, GROUP_CONCAT_DISTINCT, MAX, MIN, STDDEV, SUM) 쿼리를 제공합니다. 이 기능은 사용자 지정 보고서를 만들거나 계산된 필드를 계산할 때 유용할 수 있습니다.
통화 또는 가격 필드에서 GlideAggregate 메서드를 사용하는 경우 기준 통화 값으로 작업하게 됩니다. 표시할 사용자의 세션 통화로 집계 값을 변환해야 합니다. 통화 또는 가격 값(표시된 값)과 기준 통화 값(집계 값) 간의 환산율이 변경될 수 있기 때문에 결과가 사용자가 예상한 것과 다를 수 있습니다.
범위 지정된 GlideAggregate - GlideAggregate(String tableName)
지정된 테이블에 GlideAggregate 객체를 작성합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| tableName | 문자열 | 테이블의 이름입니다. |
var count = new GlideAggregate('incident');
범위 지정된 GlideAggregate - addAggregate(문자열 집계, 문자열 이름)
데이터베이스 쿼리에 집계를 추가합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 집계 | 문자열 | 사용할 집계의 이름입니다. 유효한 값은 다음과 같습니다.
|
| 이름 | 문자열 | 옵션입니다. 집계 결과를 그룹화할 필드의 이름입니다. 기본값: Null |
| 유형 | 설명 |
|---|---|
| 없음 |
다음 예는 인시던트 [incident] 테이블에서 GlideAggregate 함수를 사용하는 방법을 보여줍니다.
var incidentGA = new GlideAggregate('incident');
incidentGA.groupBy('category');
incidentGA.orderByAggregate('COUNT', 'sys_mod_count');
incidentGA.addAggregate('AVG', 'sys_mod_count');
incidentGA.addAggregate('COUNT', 'sys_mod_count');
incidentGA.addAggregate('GROUP_CONCAT', 'sys_mod_count');
incidentGA.addAggregate('GROUP_CONCAT_DISTINCT', 'sys_mod_count');
incidentGA.addAggregate('MAX', 'sys_mod_count');
incidentGA.addAggregate('MIN', 'sys_mod_count');
incidentGA.addAggregate('STDDEV', 'sys_mod_count');
incidentGA.addAggregate('SUM', 'sys_mod_count');
incidentGA.query();
while (incidentGA.next()) {
gs.info('CATEGORY: ' + incidentGA.getValue('category'));
gs.info('AVG: ' + incidentGA.getAggregate('AVG', 'sys_mod_count'));
gs.info('COUNT: ' + incidentGA.getAggregate('COUNT', 'sys_mod_count'));
gs.info('GROUP_CONCAT: ' + incidentGA.getAggregate('GROUP_CONCAT', 'sys_mod_count'));
gs.info('GROUP_CONCAT_DISTINCT: ' + incidentGA.getAggregate('GROUP_CONCAT_DISTINCT', 'sys_mod_count'));
gs.info('MAX: ' + incidentGA.getAggregate('MAX', 'sys_mod_count'));
gs.info('MIN: ' + incidentGA.getAggregate('MIN', 'sys_mod_count'));
gs.info('STDDEV: ' + incidentGA.getAggregate('STDDEV', 'sys_mod_count'));
gs.info('SUM: ' + incidentGA.getAggregate('SUM', 'sys_mod_count'));
gs.info(' ');
}
출력.
CATEGORY: inquiry
AVG: 8.42424242424242424242424242424242424242E00
COUNT: 33
GROUP_CONCAT: 0,0,0,0,1,2,2,4,4,4,5,5,5,6,6,6,6,6,6,6,6,7,8,8,8,8,9,15,15,19,32,33,36
GROUP_CONCAT_DISTINCT: 0,1,2,4,5,6,7,8,9,15,19,32,33,36
MAX: 36
MIN: 0
STDDEV: 9.15843294125113629932710147135171494439E00
SUM: 278
CATEGORY: software
AVG: 21
COUNT: 13
GROUP_CONCAT: 3,4,5,5,6,7,9,10,10,11,14,94,95
GROUP_CONCAT_DISTINCT: 3,4,5,6,7,9,10,11,14,94,95
MAX: 95
MIN: 3
STDDEV: 3.27693962918655755532970326989852794087E01
SUM: 273
CATEGORY: Hardware
AVG: 6.8
COUNT: 10
GROUP_CONCAT: 2,5,5,6,6,6,7,7,9,15
GROUP_CONCAT_DISTINCT: 2,5,6,7,9,15
MAX: 15
MIN: 2
STDDEV: 3.39280283999985933622820108982884699755E00
SUM: 68
CATEGORY: network
AVG: 18
COUNT: 5
GROUP_CONCAT: 3,12,17,21,37
GROUP_CONCAT_DISTINCT: 3,12,17,21,37
MAX: 37
MIN: 3
STDDEV: 1.25698050899765347157025586536136512302E01
SUM: 90
CATEGORY:
AVG: 9.5
COUNT: 4
GROUP_CONCAT: 8,8,10,12
GROUP_CONCAT_DISTINCT: 8,10,12
MAX: 12
MIN: 8
STDDEV: 1.91485421551267621995020382273964310607E00
SUM: 38
CATEGORY: database
AVG: 29
COUNT: 2
GROUP_CONCAT: 8,50
GROUP_CONCAT_DISTINCT: 8,50
MAX: 50
MIN: 8
STDDEV: 2.969848480983499602483546320840365965E01
SUM: 58
범위 지정된 GlideAggregate - addEncodedQuery(문자열 쿼리)
이 집계에 대해 설정되었을 수 있는 다른 쿼리에 인코딩된 쿼리를 추가합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 쿼리 | 문자열 | 집계에 추가할 인코딩된 쿼리입니다. |
| 유형 | 설명 |
|---|---|
| 없음 |
//Number of incidents varies depending on the current state
//of the incident table
var count = new GlideAggregate('incident');
count.addEncodedQuery('active=true');
count.addAggregate('COUNT');
count.query();
var incidents = 0;
if (count.next())
incidents = count.getAggregate('COUNT');
gs.info(incidents);
범위 지정된 GlideAggregate - addQuery(문자열 이름, 문자열 연산자, 문자열 값)
집계에 쿼리를 추가합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 이름 | 문자열 | 추가할 쿼리입니다. |
| 운영자 | 문자열 | 쿼리에 대한 연산자입니다. |
| 값 | 문자열 | 쿼리에 포함할 값의 목록입니다. |
| 유형 | 설명 |
|---|---|
| GlideQueryCondition | 쿼리 조건입니다. |
//Number of incidents varies depending on the current state
//of the incident table
var count = new GlideAggregate('incident');
count.addQuery('active', '=','true');
count.addAggregate('COUNT', 'category');
count.query();
while (count.next()) {
var category = count.category;
var categoryCount = count.getAggregate('COUNT', 'category');
gs.info("There are currently " + categoryCount + " incidents with a category of " + category);
}
There are currently 1 incidents with a category of database
There are currently 5 incidents with a category of hardware
There are currently 42 incidents with a category of inquiry
There are currently 4 incidents with a category of network
There are currently 4 incidents with a category of request
There are currently 7 incidents with a category of software범위 지정된 GlideAggregate - addNotNullQuery(String fieldName)
집계에 null이 아닌 쿼리를 추가합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 필드 이름 | 문자열 | 필드의 이름입니다. |
| 유형 | 설명 |
|---|---|
| GlideQueryCondition | 범위가 지정된 쿼리 조건입니다. |
var count = new GlideAggregate('incident');
count.addNotNullQuery('short_description');
count.query(); // Issue the query to the database to get all records
while (count.next()) {
// add code here to process the aggregate
}
범위 지정된 GlideAggregate - addNullQuery(String fieldName)
집계에 null 쿼리를 추가합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| fieldName | 문자열 | 필드의 이름입니다. |
| 유형 | 설명 |
|---|---|
| GlideQueryCondition | 범위가 지정된 쿼리 조건입니다. |
var count = new GlideAggregate('incident');
count.addNullQuery('short_description');
count.query(); // Issue the query to the database to get all records
while (count.next()) {
// add code here to process the aggregate
}
범위 지정 GlideAggregate - addTrend(String fieldName, String timeInterval, Number numUnits)
지정된 필드에 대한 추세를 추가합니다. 추세를 사용하여 일정 기간 동안의 패턴을 표시합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| fieldName | 문자열 | 추세가 발생해야 하는 필드의 이름입니다. |
| timeInterval (시간 간격) | 문자열 | 추세의 시간 간격입니다. 유효한 값은 다음과 같습니다.
|
| numUnits (숫자 단위) | 번호 | 옵션입니다. = 분인 경우에만 timeInterval 유효합니다. 추세에 포함할 시간(분)입니다. 기본값: 1 |
| 유형 | 설명 |
|---|---|
| void |
var ga = new GlideAggregate('incident');
ga.addAggregate('COUNT'); // Count all incidents opened each quarter
ga.addTrend('opened_at', 'quarter');
ga.query();
while(ga.next()) {
gs.info([ga.getValue('timeref'), ga.getAggregate('COUNT')]);
}
3/2018, 9
4/2018, 2
1/2019, 38
2/2019, 310범위 지정된 GlideAggregate - getAggregate(문자열 집계, 문자열 이름)
현재 기록에서 집계 값을 반환합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 집계 | 문자열 | 집계의 유형입니다. 유효한 값은 다음과 같습니다.
|
| 이름 | 문자열 | 집계를 수행할 필드의 이름입니다. |
| 유형 | 설명 |
|---|---|
| 문자열 | 집계의 값입니다. 집계되는 값이 FX 통화 값인 경우 반환되는 값은 <currency_code 형식입니다 . currency_value> 예: USD; 134.980000입니다. 주: 지정된 필드에 혼합 통화 유형의 FX 통화 값이 포함되어 있는 경우 메서드는 값을 집계할 수 없으며 세미콜론(;)을 반환합니다. |
인시던트 테이블의 기록 수를 반환하는 집계를 표시합니다.
var count = new GlideAggregate('incident');
count.addAggregate('COUNT');
count.query();
var incidents = 0;
if (count.next()) {
incidents = count.getAggregate('COUNT');
}
//Number of incidents varies depending on the current state
//of the incident table
gs.info('Number of incidents: ' + incidents);
출력: 인시던트 수: 63.
FX 통화 필드의 집계를 표시합니다.
var ga = new GlideAggregate('laptop_tracker');
ga.addAggregate('SUM', 'cost');
ga.groupBy('name');
ga.query();
while (ga.next()) {
gs.info('Aggregate results ' + ga.getValue('name') + ' => ' + ga.getAggregate('SUM', 'cost'));
}
출력:
*** Script: Aggregate results Apple MacBook Air => USD;1651.784280000000
*** Script: Aggregate results Apple MacBook Pro => USD;1651.784280000000
*** Script: Aggregate results Dell XPS => USD;470.852672000000
*** Script: Aggregate results LG =>
*** Script: Aggregate results Samsung Galaxy => USD;225.320000000000
*** Script: Aggregate results Surface3 => USD;2895.560369520000
*** Script: Aggregate results Toshiba => USD;9385.202875800000
범위 지정된 GlideAggregate - getAggregateEncodedQuery()
현재 집계를 반환하는 데 필요한 쿼리를 가져옵니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 문자열 | 집계를 가져오기 위해 인코딩된 쿼리입니다. |
var count = new GlideAggregate('incident');
count.addAggregate('MIN', 'sys_mod_count');
count.groupBy('category');
count.query();
while (count.next()) {
gs.info(count.getAggregateEncodedQuery());
}
category=database
category=hardware
category=inquiry
category=network
category=request
category=software범위 지정된 GlideAggregate - getEncodedQuery()
인코딩된 쿼리를 검색합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 문자열 | 인코딩된 쿼리입니다. |
var count = new GlideAggregate('incident');
count.addAggregate('MIN', 'sys_mod_count');
count.addAggregate('MAX', 'sys_mod_count');
count.addAggregate('AVG', 'sys_mod_count');
count.groupBy('category');
count.query();
gs.info(count.getEncodedQuery());
ORDERBYcategory^GROUPBYcategory범위가 지정된 GlideAggregate - getRowCount()
GlideAggregate 객체의 행 수를 검색합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 번호 | GlideAggregate 객체의 행 수입니다. |
var count = new GlideAggregate('incident');
count.addAggregate('MIN', 'sys_mod_count');
count.addAggregate('MAX', 'sys_mod_count');
count.addAggregate('AVG', 'sys_mod_count');
count.groupBy('category');
count.query();
gs.info(count.getRowCount());
while (count.next()) {
var min = count.getAggregate('MIN', 'sys_mod_count');
var max = count.getAggregate('MAX', 'sys_mod_count');
var avg = count.getAggregate('AVG', 'sys_mod_count');
var category = count.category.getDisplayValue();
gs.info(category + " Update counts: MIN = " + min + " MAX = " + max + " AVG = " + avg);
}
6
Database Update counts: MIN = 8 MAX = 48 AVG = 28.0000
Hardware Update counts: MIN = 4 MAX = 14 AVG = 6.6250
Inquiry / Help Update counts: MIN = 0 MAX = 34 AVG = 6.5714
Network Update counts: MIN = 3 MAX = 37 AVG = 18.6000
Request Update counts: MIN = 5 MAX = 39 AVG = 13.4000
Software Update counts: MIN = 4 MAX = 98 AVG = 24.0000범위가 지정된 GlideAggregate - getTableName()
이 GlideAggregate 객체와 연결된 테이블 이름을 조회합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 문자열 | 테이블 이름입니다. |
var count = new GlideAggregate('incident');
count.addAggregate('MIN', 'sys_mod_count');
count.addAggregate('MAX', 'sys_mod_count');
count.addAggregate('AVG', 'sys_mod_count');
count.groupBy('category');
count.query();
gs.info(count.getTableName());
범위 지정된 GlideAggregate - getValue(문자열 이름)
지정된 필드의 값을 반환합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 이름 | 문자열 | 반환하려는 현재 테이블 내의 필드 이름입니다. |
| 유형 | 설명 |
|---|---|
| 문자열 | 지정된 필드의 값입니다. 잘못된 경우(결과 집합의 일부가 아님) null을 반환합니다. |
var count = new GlideAggregate('incident');
count.addAggregate('MAX', 'sys_mod_count');
count.groupBy('category');
count.query();
while (count.next()) {
gs.info(count.getValue('category') + " category had " + count.getAggregate('MAX', 'sys_mod_count') + " updates");
}
출력:
category had 12 updates
hardware category had 15 updates
inquiry category had 36 updates
network category had 37 updates
software category had 95 updates
범위 지정된 GlideAggregate - groupBy(문자열 이름)
집계를 그룹화하는 데 사용할 필드의 이름을 제공합니다.
여러 그룹 필드를 설정하기 위해 여러 번 호출될 수 있습니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 이름 | 문자열 | 필드의 이름입니다. |
| 유형 | 설명 |
|---|---|
| 없음 |
var count = new GlideAggregate('incident');
count.addAggregate('MIN', 'sys_mod_count');
count.addAggregate('MAX', 'sys_mod_count');
count.addAggregate('AVG', 'sys_mod_count');
count.groupBy('category');
count.query();
while (count.next()) {
var min = count.getAggregate('MIN', 'sys_mod_count');
var max = count.getAggregate('MAX', 'sys_mod_count');
var avg = count.getAggregate('AVG', 'sys_mod_count');
var category = count.category.getDisplayValue();
gs.info(category + " Update counts: MIN = " + min + " MAX = " + max + " AVG = " + avg);
}
Database Update counts: MIN = 8 MAX = 48 AVG = 28.0000
Hardware Update counts: MIN = 4 MAX = 14 AVG = 6.6250
Inquiry / Help Update counts: MIN = 0 MAX = 34 AVG = 6.5714
Network Update counts: MIN = 3 MAX = 37 AVG = 18.6000
Request Update counts: MIN = 5 MAX = 39 AVG = 13.4000
Software Update counts: MIN = 4 MAX = 98 AVG = 24.0000
범위가 지정된 GlideAggregate - hasNext()
GlideAggregate 객체에 기록이 더 있는지 확인합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 부울 | 쿼리 세트에 더 많은 결과가 있는지 여부를 나타내는 플래그입니다. 가능한 값:
|
var agg = new GlideAggregate('incident');
agg.addAggregate('AVG', 'sys_mod_count');
agg.groupBy('category');
agg.query();
while (agg.hasNext()) {
agg.next();
var avg = agg.getAggregate('AVG', 'sys_mod_count');
var category = agg.category.getDisplayValue();
gs.info(category + ': AVG = ' + avg);
}
Database: AVG = 32.5000
Hardware: AVG = 12.0000
Inquiry / Help: AVG = 7.6667
Network: AVG = 24.0000
Request: AVG = 16.4000
Software: AVG = 27.0833범위가 지정된 GlideAggregate - next()
GlideAggregate의 다음 기록으로 이동합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 부울 | 쿼리 세트에 더 많은 결과가 있는지 여부를 나타내는 플래그입니다. 가능한 값:
|
var count = new GlideAggregate('incident');
count.addAggregate('COUNT');
count.query();
var incidents = 0;
if (count.next()) {
incidents = count.getAggregate('COUNT');
gs.info(incidents);
}
범위 지정된 GlideAggregate - orderBy(문자열 이름)
지정된 필드의 값을 사용하여 집계를 정렬합니다. 필드는 그룹 기준 목록에도 추가됩니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 이름 | 문자열 | 집계를 정렬할 필드의 이름입니다. 또는 |
| 유형 | 설명 |
|---|---|
| 없음 |
var agg = new GlideAggregate('incident');
agg.addAggregate('count', 'category');
agg.orderBy('category');
agg.query();
while (agg.next()) {
var category = agg.category;
var count = agg.getAggregate('count', 'category');
var agg2 = new GlideAggregate('incident');
agg2.addAggregate('count', 'category');
agg2.orderBy('category');
gs.info(category + ": Current number of incidents:" + count);
}
database: Current number of incidents:2
hardware: Current number of incidents:8
inquiry: Current number of incidents:28
network: Current number of incidents:5
request: Current number of incidents:5
software: Current number of incidents:11범위 지정된 GlideAggregate - orderByAggregate(String agg, String fieldName)
지정된 집계 및 필드를 기준으로 집계를 정렬합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 집계 | 문자열 | 집계 유형입니다. |
| fieldName | 문자열 | 집계할 필드의 이름입니다. |
| 유형 | 설명 |
|---|---|
| void |
ga.addAggregate('COUNT', 'category');
ga.orderByAggregate('count', 'category');
ga.query();
while(ga.next()) {
gs.info('Category: ' + ga.category + ' ' + ga.getAggregate('COUNT', 'category'));
}
출력:
Category: inquiry 18
Category: software 11
Category: hardware 7
Category: network 5
Category: request 5
Category: 4
Category: database 2
범위 지정된 GlideAggregate - orderByDesc(문자열 이름)
지정된 필드를 기준으로 집계를 내림차순으로 정렬합니다. 필드가 그룹 기준 목록에도 추가됩니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 이름 | 문자열 | 필드의 이름입니다. |
| 유형 | 설명 |
|---|---|
| 없음 |
var agg = new GlideAggregate('incident');
agg.addAggregate('count', 'category');
agg.orderByDesc('category');
agg.query();
while (agg.next()) {
var category = agg.category;
var count = agg.getAggregate('count', 'category');
var agg2 = new GlideAggregate('incident');
agg2.addAggregate('count', 'category');
agg2.orderBy('category');
gs.info(category + ": Current number of incidents:" + count);
}
software: Current number of incidents:11
request: Current number of incidents:5
network: Current number of incidents:5
inquiry: Current number of incidents:28
hardware: Current number of incidents:8
database: Current number of incidents:2
범위가 지정된 GlideAggregate - query()
쿼리를 실행하고 결과를 가져옵니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 없음 |
var count = new GlideAggregate('incident');
count.addAggregate('COUNT');
count.query();
var incidents = 0;
if (count.next()) {
incidents = count.getAggregate('COUNT');
}
gs.info('Number of incidents: ' + incidents);
범위 지정된 GlideAggregate - setAggregateWindow(Number firstRow, Number lastRow)
집계 쿼리에 포함할 테이블의 행 수를 제한합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 첫 번째 행 | 번호 | 집계 쿼리에 포함할 첫 번째 행의 인덱스(0부터 시작)입니다. |
| lastRow (마지막 행) | 번호 | 집계 쿼리에 포함할 마지막 행의 인덱스(0부터 시작)입니다(제외). |
| 유형 | 설명 |
|---|---|
| 없음 |
인시던트 [incident] 테이블의 처음 10개 기록에 대한 각 범주의 카운트를 인쇄합니다.
var incidentGroup = new GlideAggregate('incident');
incidentGroup.addAggregate('COUNT', 'category');
incidentGroup.setAggregateWindow(0, 10);
incidentGroup.query();
while (incidentGroup.next()) {
var incidentCount = incidentGroup.getAggregate('COUNT', 'category');
gs.info('{0} count: {1}', [incidentGroup.getValue('category'), incidentCount]);
}
출력:
database count: 1
Hardware count: 1
inquiry count: 7
software count: 1
범위 지정된 GlideAggregate - setGroup(부울 b)
반환 결과를 그룹화할지 여부를 설정합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| b | 부울 | 결과를 그룹화할지 여부를 나타내는 플래그입니다. 유효한 값은 다음과 같습니다.
|
| 유형 | 설명 |
|---|---|
| void |
var ga = new GlideAggregate('incident');
ga.addAggregate('COUNT', 'category');
ga.setGroup(true);
ga.groupBy("category");
ga.query();
while(ga.next()) {
gs.info('Category ' + ga.category + ' ' + ga.getAggregate('COUNT', 'category'));
}
출력:
Category database 2
Category hardware 7
Category inquiry 18
Category network 5
Category request 5
Category software 11
범위 지정된 GlideAggregate - setIntervalYearIncluded(부울 b)
요일 추세에 대해 결과를 연도별로 그룹화할지 여부를 설정합니다. 이러한 추세는 시간 간격과 dayofweek 함께 addTrend() 메서드를 사용하여 생성됩니다.
종속성: 범위 지정 GlideAggregate - addTrend("<fieldName>", "dayofweek").
| 이름 | 유형 | 설명 |
|---|---|---|
| b | 부울 | 요일 시간 간격이 있는 추세에 연도를 포함할지 여부를 나타내는 플래그입니다. 유효한 값은 다음과 같습니다.
기본값: true |
| 유형 | 설명 |
|---|---|
| 없음 |
다음 예에서는 지난 6개월 동안 생성된 인시던트를 계산하는 방법을 보여 줍니다. 인시던트는 요일로 구분되지만 연도는 포함되지 않습니다. 예를 들어 목요일의 기본 결과에는 연도가 포함됩니다(예: Thursday/2023: 16).
var incidentGroup = new GlideAggregate('incident');
incidentGroup.addEncodedQuery("sys_created_onRELATIVEGT@month@ago@6");
incidentGroup.addTrend('sys_created_on', 'dayofweek');
incidentGroup.addAggregate('COUNT');
incidentGroup.setIntervalYearIncluded(false);
incidentGroup.query();
while (incidentGroup.next()) {
gs.info(incidentGroup.getValue('timeref') + ': ' + incidentGroup.getAggregate('COUNT'))};
출력:
Sunday: 1
Monday: 15
Tuesday: 1
Wednesday: 7
Thursday: 16
Saturday: 1