SQL, Java, polymorphism, Joins.
Use the schema below to treat account_type as a discriminator for polymorphic account behavior. Write a PostgreSQL query that returns every open account, including accounts without qualifying events. Include only events posted during 2025; account-level totals must remain zero when no such events exist.
Output
- One row per open account with
customer_name, account_id, account_type, account_label, event_count, and total_amount
account_label must identify the account type, and NULL event amounts must not inflate totals
- Sort by
customer_name, then account_id ascending