Postgres Query:
SELECT
((data->>'date')) AS time,
((data->>'totalAmount')) as values
FROM invoices
输出:
<表类>id 日期 总量 tbody><<tr>1 2021-01-16 13 22021-01-12 52 3 2020-12-17 11 42020-12-08 3 表类>
您需要将文本值转换为date
,然后您可以例如使用to_char()
从中获取月份:
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')