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

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.

主站蜘蛛池模板: 长子县| 吉林市| 昂仁县| 博湖县| 湘潭市| 多伦县| 红河县| 新河县| 兴国县| 丽江市| 澳门| 新丰县| 洪泽县| 甘谷县| 阳谷县| 河北省| 肥乡县| 南宫市| 阳东县| 青河县| 清涧县| 隆德县| 崇文区| 华宁县| 绥江县| 临沂市| 乌拉特中旗| 祁阳县| 萍乡市| 安泽县| 尼勒克县| 屯门区| 南昌市| 泗洪县| 屏东市| 仪征市| 柞水县| 云和县| 平安县| 绩溪县| 木里|