Describe your experience with SQL queries, how do you handle complex joins when analyzing production data for Citi?
Write a PostgreSQL query using the provided Citi production query catalog, run history, and data source metadata. Return production queries from January 2025 that ran at least twice and had at least one failure.
Output
- One row per qualifying production query with
query_id, query_name, source_name, total_runs, failed_runs, avg_success_duration_seconds, and latest_status.
- Use
Unknown source when source metadata is unavailable. Sort by failed_runs descending, then query_id ascending.
Output details
- Include runs started from
2025-01-01 inclusively through 2025-02-01 exclusively.
- Count all qualifying runs, count only status
failed as failures, and average durations only for status success.
- Round
avg_success_duration_seconds to two decimal places and return NULL when no successful run has a duration.
- Select the latest status by greatest
started_at, breaking ties with greatest run_id.