Payment Mix by Year
For each year of paid_on return year (as text, like '2025') and the percentage of that year's payments made by each method as card_percent, wallet_percent, transfer_percent and cash_percent, each rounded to 1 decimal. Sort by year.
Hint 1
STRFTIME('%Y', paid_on) gives the year as text.
Hint 2
Each percentage is 100.0 * SUM(CASE WHEN method = '...' THEN 1 ELSE 0 END) / COUNT(*).
Reference solution
SELECT STRFTIME('%Y', paid_on) AS year,
ROUND(100.0 * SUM(CASE WHEN method = 'card' THEN 1 ELSE 0 END) / COUNT(*), 1) AS card_percent,
ROUND(100.0 * SUM(CASE WHEN method = 'wallet' THEN 1 ELSE 0 END) / COUNT(*), 1) AS wallet_percent,
ROUND(100.0 * SUM(CASE WHEN method = 'transfer' THEN 1 ELSE 0 END) / COUNT(*), 1) AS transfer_percent,
ROUND(100.0 * SUM(CASE WHEN method = 'cash' THEN 1 ELSE 0 END) / COUNT(*), 1) AS cash_percent
FROM payments
GROUP BY STRFTIME('%Y', paid_on)
ORDER BY year;
Inside a grouped query, COUNT(*) is the number of payments in that year, which is the right denominator for "share within the year". The percentages of one row add up to 100 (apart from rounding), which is a good sanity check to run on every share-of-total report.