SQL & Reporting

Halo ITSM

A growing library of SQL queries, reporting patterns, SLA/OLA logic, and dashboard helpers — built from real-world use.

SQL Scripts & Snippets

Small filters and helpers you can drop straight into Halo reports

HALO Scoped reporting by agent team Limit faults to the logged-in agent’s team(s)

Limit faults to the logged-in agent’s team(s)

By default, SQL reports can return faults across every team. This filter scopes the result set so each agent only sees faults where faults.sectio_ matches one of their section memberships.

WHERE clause filter
AND EXISTS (
    SELECT 1
    FROM unamesection us
    JOIN sectiondetail sd ON sd.SdId = us.USSdid
    WHERE us.USUnum = $agentid
      AND UPPER(LTRIM(RTRIM(sd.SDSectionName))) = UPPER(LTRIM(RTRIM(faults.sectio_)))
)

How it works

  • $agentid resolves to the logged-in agent’s user ID.
  • unamesection links a user (USUnum) to section membership.
  • sectiondetail contains the section name used for comparison.
  • The EXISTS check passes if any team match is found.
  • UPPER/LTRIM/RTRIM normalises casing and whitespace.

Where to use it

  • Agent-facing dashboards and reports
  • Multi-team environments (Service Desk, Infrastructure, Cyber Security)
  • Any fault-based report where permissions alone don’t give clean scope

Support the build