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

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.

主站蜘蛛池模板: 杭州市| 那曲县| 平昌县| 元江| 东辽县| 屯昌县| 南京市| 北流市| 施甸县| 沾益县| 康马县| 商南县| 阿瓦提县| 盘山县| 沁源县| 涞水县| 延长县| 迭部县| 成都市| 五家渠市| 雅安市| 马龙县| 山阳县| 石城县| 房产| 色达县| 兴安盟| 泸水县| 五原县| 九寨沟县| 株洲市| 镇沅| 六安市| 桃园县| 鄂托克前旗| 青铜峡市| 来凤县| 青州市| 巧家县| 和硕县| 郎溪县|