| Version 1 (modified by , 5 days ago) ( diff ) |
|---|
Сметки со највисоко вкупно трошење во изминатата година
SELECT
ta.account_name,
SUM(tb.spent_amount) AS total_spent
FROM
transaction_breakdown tb
JOIN transaction t ON tb.transaction_id = t.transaction_id
JOIN transaction_account ta ON tb.transaction_account_id = ta.transaction_account_id
WHERE
t.date >= NOW() - INTERVAL '1 YEAR'
GROUP BY
ta.account_name
ORDER BY
total_spent DESC
LIMIT 10;
Note:
See TracWiki
for help on using the wiki.
