I have a simple JSON array:
_bb jsonb =
[
{
"so": "1",
"mdl": "Testing",
"pos": "Top"
},
{
"so": "1",
"mdl": "FlashSale",
"pos": "Bottom"
},
{
"so": "1",
"mdl": "Testing",
"pos": "Top"
}
]
What I want to achieve:
[
{
"so": "1",
"mdl": "Testing",
"pos": "Top"
},
{
"so": "1",
"mdl": "Testing",
"pos": "Top"
},
{
"so": "1",
"mdl": "FlashSale",
"pos": "Bottom"
}
]
I tried doing
Select _bb into _test ORDER BY _bb->>'pos' ASC ;
What I achieve is all the pos = "Top" be the first in the JSON and all the "Bottom" to be last. Is there a way to achieve this in Postgres?