Correction, the start of period should be in the query a total of 3 times:
select date_add($periodstart, INTERVAL quarter*3 MONTH) as StartOfQuarter, `countsales`, countpurchases
from
(
select
floor(period_diff(date_format(`date`, '%Y%m'), date_format($periodstart, '%Y%m')) / 3) as quarter,
count(sale) as countsales, count(purchases) as countpurchases
from tbl
group by floor(period_diff(date_format(`date`, '%Y%m'), date_format($periodstart, '%Y%m')) / 3)
) sq
order by 1