Answer the question
In order to leave comments, you need to log in
How to select data from a field in json format in Postgres?
Let's say there is a table with columns id, data.
Data contains an array in json format, which has a key, for example name.
How to write a query that would select id and name as a result?
In general, the specific task is to take the sum of the parameter from the json array for a certain sample.
Those. there is a table
id - date - data
1 - 01/01/2017 - {cost:2, name:"x"}
2 - 01/01/2017 - {cost:3, name:"x1"}
4 - 01/02/2017 - {cost: 4, name:"x5"}
For example, you need to take the amount of cost for date =
01/01/2017 query result
date - sum
01.01.2017 - 5
Is it possible to write such a query in Postgres at all?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question