I wants to get all subscriptions with interval "1 WEEK" from the following 'data' column
[
{
"id": "tran_6ac25129951962e99f28fa488993",
"amount": 1200,
"client": {
"id": "client_622bdf4cce2351f28243",
"subscription": [
{
"id": "sub_a67d59efb2bcbf73485a",
"amount": 3900,
"currency": "USD",
"interval": "1 WEEK"
},
{
"id": "sub_a67d59efb2bcbf73485a",
"amount": 3900,
"currency": "USD",
"interval": "1 WEEK"
}
]
},
"currency": "USD"
},
{
"id": "tran_xxxxxxx",
"amount": 1200,
"client": {
"id": "client_xxxxxx8243",
"subscription": [
{
"id": "sub_xxefb2bcbf73485a",
"amount": 3900,
"currency": "USD",
"interval": "1 Year"
},
{
"id": "sub_yyyyyb2bcbf73485a",
"amount": 3900,
"currency": "USD",
"interval": "1 WEEK"
}
]
},
"currency": "USD"
}
]
My table structure:
CREATE TABLE transactions
(
data json,
id bigserial NOT NULL,
created_date time without time zone,
CONSTRAINT transactions_pkey PRIMARY KEY (id)
)
In output I wants to get all "1 WEEk" subscription as rows. Above data should give 3 rows
I am using Postgres 9.3+