Wildcarding json keys in json query

Поиск
Список
Период
Сортировка
От David Gauthier
Тема Wildcarding json keys in json query
Дата
Msg-id CAMBRECCKusTv=uNUp6JoBjvHog1vutf3gqO2gFJ__xgamCBFrw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Wildcarding json keys in json query
RE: Wildcarding json keys in json query
Список pgsql-general
PG 11.5 on linux

Let's say I store a jsonb in a column called test_results that looks like this...

{
ports : {
    port_abc:{min: 5, max: 7, mean: 6},
    port_def:{min: 5, max: 9, mean: 7},
    port_ghi:{min: 6, max: 10, mean: 8}
    }
}

And I want to to get all the port names where the mean is >= 7.

This works...

select 1 from mytbl where cast(test_results#>'{ports,port_abc,mean}' as float) >= 7 ;

But I want all the ports that have mean >= 7.
Something akin to...

select 1 from mytbl where cast(test_results#>'{ports,*,mean}' as float) >= 7 ;

But the "*" doesn't work :-(

Any ideas ?
Thanks!

В списке pgsql-general по дате отправления:

Предыдущее
От: Wicher
Дата:
Сообщение: Re: How to reveal the codes of functions properly?
Следующее
От: Daniel Gustafsson
Дата:
Сообщение: Re: Issues cross-compiling libpq 14.x to MacOS armv8