Courseiva
Working with DatamediumMultiple ChoiceObjective-mapped

SNOW-CAD Working with Data Practice Question

A developer needs to find the number of open incidents assigned to each assignment group. Which GlideAggregate script correctly groups by assignment group and counts?

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

var ga = new GlideAggregate('incident'); ga.addQuery('active', true); ga.addAggregate('COUNT'); ga.groupBy('assignment_group'); ga.query();

The GlideAggregate API requires addQuery() to filter open incidents, then addAggregate('COUNT') to define the aggregation, then groupBy('assignment_group') to specify the grouping field, and finally query() to execute. Option A is wrong because it uses addAggregate('COUNT', 'assignment_group'), which incorrectly passes the grouping field as a second parameter; the correct method is separate groupBy() call. Option B is wrong because getRowCount() returns the number of rows after query(), not the count per group; also missing addAggregate(). Option C is wrong because it uses get() instead of query() and the order of methods is incorrect; get() is for fetching a single record, not aggregate queries.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • var ga = new GlideAggregate('incident'); ga.addQuery('active', true); ga.addAggregate('COUNT', 'assignment_group'); ga.query();

    Why it's wrong here

    addAggregate with two arguments is for specific aggregation, but groupBy is missing; this will count all records.

  • var ga = new GlideAggregate('incident'); ga.addQuery('active', true); ga.groupBy('assignment_group'); var count = ga.getRowCount();

    Why it's wrong here

    getRowCount() returns the number of groups, but without addAggregate it's not correct.

  • var ga = new GlideAggregate('incident'); ga.get('active', true); ga.groupBy('assignment_group'); ga.addAggregate('COUNT');

    Why it's wrong here

    get() is not used for aggregates; query() is required.

  • var ga = new GlideAggregate('incident'); ga.addQuery('active', true); ga.addAggregate('COUNT'); ga.groupBy('assignment_group'); ga.query();

    Why this is correct

    Correctly queries, groups, and aggregates.

About these practice questions

Courseiva writes every SNOW-CAD question from scratch — 481 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This SNOW-CAD practice question is part of Courseiva's free ServiceNow certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SNOW-CAD exam.