Sorry for the formatting on this. There's too much text to create a readable table, so bear with me.
I have a table called 'declines'. It has two columns: 'id' and 'dec_reasons'.
For id = 34254, this is the 'dec_reasons' value in JSONB format:
[
{
"id": 94748,
"reason": "Lead Fico Threshold is not Greater Than Or Equal To 500",
"created_at": "2019-05-02T07:57:59.706448",
"decline_code": "fico_too_low",
"leaf_node_id": 7,
"decision_type": "credit",
"triggers_noaa": true,
"general_description": "FICO score is too low"
},
{
"id": 94747,
"reason": "Fico score is very low",
"created_at": "2019-05-02T07:57:59.705578",
"decline_code": "fico_too_low",
"leaf_node_id": 5,
"decision_type": "credit",
"triggers_noaa": true,
"general_description": "FICO score is too low"
}
]
For id = 34257, this is the 'dec_reasons' value in JSONB format:
[
{
"id": 94772,
"reason": "Lead Fico Threshold is not Greater Than Or Equal To 500",
"created_at": "2019-05-02T07:58:05.988900",
"decline_code": "fico_too_low",
"leaf_node_id": 7,
"decision_type": "credit",
"triggers_noaa": true,
"general_description": "FICO score is too low"
},
{
"id": 94771,
"reason": "Fico score is very low",
"created_at": "2019-05-02T07:58:05.964931",
"decline_code": "fico_too_low",
"leaf_node_id": 5,
"decision_type": "credit",
"triggers_noaa": true,
"general_description": "FICO score is too low"
}
]
In each 'dec_reasons' value, there are multiple instances of the 'reason' key. How can I query for the value paired with the 1st instance of 'reason' in each 'dec_reasons' value?
If I queried the for the first instance of the 'reason' key, I'd want to see:
'Lead Fico Threshold is not Greater Than Or Equal To 500'
If I queried the for the second instance of the 'reason' key, I'd want to see:
'Fico score is very low'