SELECT t1.billing_country as country, t1.total_invoice as total_invoice, c.total_customer
FROM (
SELECT
billing_country,
EXTRACT(year from CAST(invoice_date as date)) as year,
COUNT(invoice_id) as total_invoice
FROM
invoice
WHERE EXTRACT(month from CAST(invoice_date as date)) IN (6,7,8)
group by year, billing_country
order by total_invoice desc
) as t1
LEFT JOIN
(
SELECT country,
count(customer_id) as total_customer
FROM
client
GROUP BY country
) as c
ON t1.billing_country = c.country
GROUP BY t1.billing_country, t1.total_invoice, c.total_customer
ORDER BY t1.total_invoice desc, t1.billing_country