官术网_书友最值得收藏!

GlideAggregate

The GlideAggregate class is an extension of GlideRecord and works in a similar way. The difference is that GlideRecord tends to give you database objects whereas GlideAggregate deals in counts and numbers.

We'll take a quick look at how GlideAggregate works:

var counter = new GlideAggregate('incident');
counter.addAggregate('COUNT');
counter.query();
if (counter.next()) {
var noOfIncidents = counter.getAggregate('COUNT');
}

This first example will give us the number of incidents in the database and place it in the noOfIncidents field. We can add addQuery lines in exactly the same way we would for GlideRecord if we wanted to reduce the number of incident records we returned.

As well as COUNT, we can also use SUM, MAX, MIN, and AVG to get the total sum, maximum number, minimum number, and average, respectively.

I don't find GlideAggregate used that regularly, but it is an efficient way to count records.

主站蜘蛛池模板: 南投市| 丹巴县| 曲周县| 通江县| 临高县| 临沧市| 正宁县| 江都市| 庆安县| 多伦县| 乌审旗| 彭州市| 聊城市| 金山区| 石楼县| 马关县| 循化| 垣曲县| 湾仔区| 夏邑县| 彰化市| 将乐县| 隆德县| 运城市| 郴州市| 青川县| 凤庆县| 托克托县| 云浮市| 陇南市| 体育| 包头市| 荥阳市| 虎林市| 桑植县| 涪陵区| 德钦县| 疏勒县| 玛曲县| 南充市| 金溪县|