You need to cast the text value to a date
then you can e.g. use to_char()
to get just the month from it:
select to_char((data->>'date')::date, 'yyyy-mm') AS month,
sum((data->>'totalAmount')::int) as values
from invoices
group by to_char((data->>'date')::date, 'yyyy-mm')
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…