Example Queries

Practical SQL query examples that combine multiple reporting views for common analytics use cases.

This page provides ready-to-use SQL queries for common reporting scenarios. Each query combines multiple views and can be adapted to your specific needs. All queries use the reporting schema.

circle-info

These queries are illustrative. Your label categories, custom fields, and workflow statuses may differ. Adjust filter values to match your configuration.


Operational overview

Daily issue summary by category and priority
SELECT
    i.category_name,
    i.priority,
    COUNT(*) AS issues_today,
    COUNT(*) FILTER (WHERE i.current_status = 'closed') AS closed_today
FROM reporting.issues i
WHERE i.created_at::date = CURRENT_DATE
GROUP BY i.category_name, i.priority
ORDER BY issues_today DESC;
Open actions past due date
SELECT
    a.action_number,
    a.title,
    a.due_date,
    a.current_status,
    u.first_name || ' ' || u.last_name AS assignee
FROM reporting.actions a
LEFT JOIN reporting.users u
    ON a.assignee_type = 'user'
    AND a.assignee_id = u.user_id
WHERE a.current_status NOT IN ('completed', 'cancelled')
    AND a.due_date < NOW()
ORDER BY a.due_date ASC;

Checklists & quality


Issue resolution & root cause


Training & compliance


Safety (BOS)


Production

Last updated