Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
statistics
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
drop table if exists my_table; create table my_table(id serial primary key, event_id integer, answers jsonb); insert into my_table (event_id, answers) values (10, '{"colores": ["Rojo", "Verde", "Azul"]}'::jsonb), (10, '{"colores": ["Amarillo", "Verde"]}'), (10, '{"colores": ["Azul"]}'), (10, '{"maderas": ["pino"]}'); SELECT jsonb_array_elements_text(answers->'colores') AS colores, count(id) FROM my_table WHERE event_id = 10 GROUP BY colores;
absolute service time: 0,43 sec
edit mode
|
history
|
discussion
colores
count
1
Amarillo
1
2
Azul
2
3
Rojo
1
4
Verde
2