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

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.

主站蜘蛛池模板: 邵阳县| 铁岭县| 黄石市| 南溪县| 苍梧县| 海阳市| 扎赉特旗| SHOW| 蒙阴县| 宁南县| 文安县| 惠来县| 屏东县| 惠安县| 仁寿县| 阜平县| 崇文区| 正镶白旗| 扎鲁特旗| 红原县| 永仁县| 辛集市| 菏泽市| 鄂州市| 加查县| 余庆县| 工布江达县| 临沭县| 苍南县| 广德县| 宁德市| 永德县| 宜都市| 长岛县| 佛教| 葵青区| 米脂县| 德江县| 天长市| 聂拉木县| 大余县|