You are given partner error logs and a lookup of error codes. Write a PostgreSQL query that identifies the top failure modes by partner, showing each partner’s error category, the number of occurrences, and the share of that partner’s total errors. Focus on the most frequent failure modes and exclude partners with no logged errors.
Output details
- Return columns
partner_id, error_category, error_count, total_errors, and error_share in that order.
- Sort by
partner_id ascending, then error_count descending, then error_category ascending.
- Round
error_share to four decimal places.
- Exclude error records where
error_code is NULL.
- Label error codes absent from the lookup as
Unknown / unmapped.
- Count every qualifying error record without deduplication and return all qualifying categories without a row limit.