---
id: change/bcquality/215
type: change
title: "#215 knowledge(performance): grouped query (Count + ColumnFilter = HAVING) for distinct values and duplicates"
summary: A new performance knowledge article teaches developers how to use query objects with grouped methods and column filters to detect duplicate values in a single SQL statement instead of looping with multiple queries.
tier: official
language: en
tags:
  - feature
  - main
system: development
review:
  state: reviewed
  by: opus
  at: "2026-10-08T02:03:02.004Z"
  flags: []
generated:
  at: "2026-10-08T01:26:53.141Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: 4405c97c579f2d8c04b0d87f4cc0df25de161a96
evidence:
  - kind: code
    url: https://github.com/microsoft/BCQuality/pull/215
    title: "microsoft/BCQuality#215: knowledge(performance): grouped query (Count + ColumnFilter = HAVING) for distinct values and duplicates"
    date: "2026-10-05"
    commit: 4405c97c579f2d8c04b0d87f4cc0df25de161a96
    t: null
    quote: A query object does it in one statement.
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
number: 215
repo: microsoft/BCQuality
source_id: bcquality-prs
url: https://github.com/microsoft/BCQuality/pull/215
kind: pr
base_branch: main
major: null
merged_at: "2026-10-05T12:59:16Z"
author: MichaelDieringer
author_type: User
community_contribution: false
labels: []
change_class: code
change_kind: feature
behavior_change: false
breaking: false
files:
  count: 5
  additions: 110
  deletions: 1
  al: 4
apps: []
objects_touched: []
objects_unjoined:
  - path: microsoft/knowledge/performance/use-grouped-query-for-distinct-values-and-duplicates.bad.al
    status: added
    reason: not-in-snapshot
  - path: microsoft/knowledge/performance/use-grouped-query-for-distinct-values-and-duplicates.good.al
    status: added
    reason: not-in-snapshot
  - path: microsoft/knowledge/performance/use-grouped-query-for-distinct-values-and-duplicates.md
    status: added
    reason: not-in-snapshot
  - path: microsoft/skills/review/al-performance-review.md
    status: modified
    reason: not-in-snapshot
obsoletions: []
backports: []
fixes_issues: []
work_items: []
systems:
  - development
  - platform
quote: A query object does it in one statement.
joined_against:
  major: null
  commit: null
---

# #215 knowledge(performance): grouped query (Count + ColumnFilter = HAVING) for distinct values and duplicates

> A new performance knowledge article teaches developers how to use query objects with grouped methods and column filters to detect duplicate values in a single SQL statement instead of looping with multiple queries.

[Pull request](https://github.com/microsoft/BCQuality/pull/215) · merged into `main` on 2026-10-05 by MichaelDieringer · 5 files (+110 -1), 4 AL · feature · tier official · reviewed (checked by Opus)

## What changed

- Query objects with aggregate methods and HAVING filters replace loop-based duplicate detection
- Reduces SQL statements from table row count to one statement
- Complements existing guidance on grouped totals
- Includes code examples and verification against base application usage
- Added to performance review skill with filter-and-count loop detection

## AL objects touched

- `microsoft/knowledge/performance/use-grouped-query-for-distinct-values-and-duplicates.bad.al`: added, not in the BC? snapshot yet
- `microsoft/knowledge/performance/use-grouped-query-for-distinct-values-and-duplicates.good.al`: added, not in the BC? snapshot yet
- `microsoft/knowledge/performance/use-grouped-query-for-distinct-values-and-duplicates.md`: added, not in the BC? snapshot yet
- `microsoft/skills/review/al-performance-review.md`: modified, not in the BC? snapshot

## Context

- Systems: development, platform
- From the description: "A query object does it in one statement."

Source: metadata of a merged pull request in microsoft/BCQuality (bcquality): title, labels, changed paths and counts, with a summary in our words. No source text and no description beyond one short quote (D10, D61).
