select sum from other table using group by
<p>I have two tables "invoices" and "invoices_account"</p>

<p>by query</p>

<pre><code>SELECT DATE_FORMAT(inv_created, '%Y') as 'year',
       COUNT(*) as 'total' 
FROM invoices as i 
WHERE inv_way = "OUT" 
GROUP BY DATE_FORMAT(inv_created, '%Y')
</code></pre>

<p>I get amount of invoices per year like:</p>

<pre><code>2011 | 80
2012 | 120
</code></pre>

<p>and so on.</p>

<p>What I need is to get summary of all entries from "invoices_account"."inv_total" by year in the first query. Relation is 1:1. That means that 80 invoices from 2011 have 80 rows in "invoices_account". And I need to have something like this</p>

<pre><code>2011 | 80  | 1.000.000 €
2012 | 120 | 230.000.000 €
</code></pre>