GlideAggregate: スコープ指定
GlideAggregate API を使用すると、データベース集計クエリを作成できます。
GlideAggregate クラスは GlideRecord クラスの拡張であり、データベースアグリゲーション (AVG、COUNT、GROUP_CONCAT、GROUP_CONCAT_DISTINCT、MAX、MIN、STDDEV、SUM) クエリを提供します。この機能は、カスタマイズされたレポートを作成するときや計算フィールドを計算する場合に役立ちます。
通貨または価格フィールドで GlideAggregate メソッドを使用する場合は、参照通貨値で作業します。表示するには、集計値をユーザーのセッション通貨に変換してください。通貨または価格の値 (表示値) とその参照 通貨 値 (集計値) との間の換算レートが変化する可能性があるため、結果がユーザーの期待と異なる場合があります。
スコープ対象 GlideAggregate:GlideAggregate(文字列 tableName)
指定されたテーブルに GlideAggregate オブジェクトを作成します。
| 名前 | タイプ | 説明 |
|---|---|---|
| tableName | 文字列 | テーブルの名前です。 |
var count = new GlideAggregate('incident');
スコープ対象 GlideAggregate - addAggregate(String agg, String name)
集計をデータベースクエリに追加します。
| 名前 | タイプ | 説明 |
|---|---|---|
| 集計 | 文字列 | 使用するアグリゲートの名前。 有効な値:
|
| name | 文字列 | オプション。集計結果をグループ化するフィールドの名前。 デフォルト: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(文字列クエリ)
このアグリゲートに設定されている可能性がある他のクエリに、エンコードされたクエリを追加します。
| 名前 | タイプ | 説明 |
|---|---|---|
| query | 文字列 | アグリゲートに追加するエンコードされたクエリ。 |
| タイプ | 説明 |
|---|---|
| なし |
//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(文字列名, 文字列演算子, 文字列値)
アグリゲートにクエリを追加します。
| 名前 | タイプ | 説明 |
|---|---|---|
| name | 文字列 | 追加するクエリ。 |
| オペレーター | 文字列 | クエリの演算子。 |
| value | 文字列 | クエリに含める値のリスト。 |
| タイプ | 説明 |
|---|---|
| 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 以外のクエリを追加します。
| 名前 | タイプ | 説明 |
|---|---|---|
| fieldname | 文字列 | フィールドの名前 |
| タイプ | 説明 |
|---|---|
| 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(文字列 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 = 分の場合にのみ有効です。傾向に含める分数。 デフォルト値:1 |
| タイプ | 説明 |
|---|---|
| なし |
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(文字列集計、文字列名)
現在のレコードから集計値を返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| 集計 | 文字列 | アグリゲートのタイプ。 有効な値:
|
| name | 文字列 | 集計を実行するフィールドの名前。 |
| タイプ | 説明 |
|---|---|
| 文字列 | 集計の値。 集計される値が 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(文字列名)
指定されたフィールドの値を返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| name | 文字列 | 返す現在のテーブル内のフィールドの名前。 |
| タイプ | 説明 |
|---|---|
| 文字列 | 指定されたフィールドの値。無効な場合 (結果セットの一部ではない) は 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(文字列名)
集計のグループ化に使用するフィールドの名前を指定します。
複数のグループフィールドを設定するために、複数回呼び出される場合があります。
| 名前 | タイプ | 説明 |
|---|---|---|
| name | 文字列 | フィールドの名前 |
| タイプ | 説明 |
|---|---|
| なし |
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(文字列名)
指定されたフィールドの値を使用して集計を並べ替えます。このフィールドはグループ別リストにも追加されます。
| 名前 | タイプ | 説明 |
|---|---|---|
| name | 文字列 | 集計を並べ替えるフィールドの名前。 または、 |
| タイプ | 説明 |
|---|---|
| なし |
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 | 文字列 | アグリゲートするフィールドの名前。 |
| タイプ | 説明 |
|---|---|
| なし |
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(文字列名)
指定されたフィールドに基づいて集計を降順でソートします。このフィールドは、グループ別リストにも追加されます。
| 名前 | タイプ | 説明 |
|---|---|---|
| name | 文字列 | フィールドの名前 |
| タイプ | 説明 |
|---|---|
| なし |
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 | 番号 | 集計クエリに含める最後の行のゼロベースのインデックス (排他的)。 |
| タイプ | 説明 |
|---|---|
| なし |
インシデント [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 - setAggregateWorkflow(ブールワークフロー)
集計クエリのビジネスルールの実行をアクティブまたは非アクティブにします。
セッションレベルのワークフロー設定 (gs.getSession().setWorkflow()) は、このメソッドを上書きします。セッションワークフローを非アクティブ化すると、このメソッドの設定に関係なく、クエリビジネスルールは実行されません。
| 名前 | タイプ | 説明 |
|---|---|---|
| ワークフロー | ブーリアン | 現在の GlideAggregate クエリに対してビジネスルールがアクティブかどうかを示すフラグ。 有効な値:
デフォルト値:false |
| タイプ | 説明 |
|---|---|
| なし |
次の例は、集計クエリのビジネスルールを有効にする方法を示しています。
var incidentGA = new GlideAggregate('incident');
incidentGA.setAggregateWorkflow(true); // activate business rules for this aggregate
incidentGA.addAggregate('COUNT', 'sys_mod_count');
incidentGA.query();
glide.businessrule.callstack プロパティがシステムプロパティ [sys_properties] テーブルにあり、true に設定されている場合、出力にはビジネスルール実行ログが含まれます。パフォーマンスへの影響を避けるために、不要な場合はこのプロパティを false に設定します。
BUSINESS RULE - About to execute business rule 'incident query' on incident:<span class = "session-log-bold-text"> </span>
BUSINESS RULE - Finished executing business rule 'incident query' on incident:<span class = "session-log-bold-text"> </span>
スコープ対象 GlideAggregate:setGroup(Boolean b)
返される結果をグループ化するかどうかを設定します。
| 名前 | タイプ | 説明 |
|---|---|---|
| b | ブーリアン | 結果をグループ化するかどうかを示すフラグ。 有効な値:
|
| タイプ | 説明 |
|---|---|
| なし |
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(Boolean b)
曜日の傾向の結果を年別にグループ化するかどうかを設定します。これらの傾向は、dayofweek時間間隔の addTrend() メソッドを使用して作成されます。
依存関係:スコープ付き GlideAggregate - addTrend('<fieldName>', 'dayofweek')。
| 名前 | タイプ | 説明 |
|---|---|---|
| b | ブーリアン | 曜日の時間間隔で傾向に年を含めるかどうかを示すフラグ。 有効な値:
デフォルト:true |
| タイプ | 説明 |
|---|---|
| なし |
次の例は、過去 6 か月間に作成されたインシデントをカウントする方法を示しています。インシデントは曜日ごとに分けられますが、年は含まれません。たとえば、木曜日のデフォルトの結果には年が含まれます ( 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