Monthly Card Issuance Variance
Beginner Mode
Objective
Write a SQL query to calculate the variance in monthly card issuance for each credit card.
Table Schema:
- card_issuance
| Column | Type | Description |
|---|---|---|
| issue_id | INTEGER | Unique identifier for each issuance record |
| card_name | VARCHAR | Name of the credit card |
| issued_amount | INTEGER | Number of cards issued |
| issue_month | DATE | Month of issuance |
| issue_year | INTEGER | Year of issuance |
Task Requirements:
- Find the maximum issued amount for each card across all months
- Find the minimum issued amount for each card across all months
- Calculate the difference (max - min) for each card
- Sort results by the difference in descending order
Output columns: card_name, issued_difference
Examples
Example 1:
Output:
Input:
| card_issuance | ||||
|---|---|---|---|---|
| card_name | issue_id | issue_month | issue_year | issued_amount |
| Chase Sapphire | 1 | 2023-01-01 | 2023 | 5000 |
| Chase Sapphire | 2 | 2023-02-01 | 2023 | 8000 |
| AmEx Gold | 3 | 2023-01-01 | 2023 | 3000 |
| AmEx Gold | 4 | 2023-02-01 | 2023 | 3500 |
| card_name | issued_difference |
|---|---|
| Chase Sapphire | 3000 |
| AmEx Gold | 500 |
Code Environment
Sign in or try as guest to run your code.
Track
| Question | Difficulty | Company | Access |
|---|
Need more practice in this area? Explore more questions →
JPMorgan