In my DB, I currently have a table that goes like this:
| order_id | country | data |
|---|---|---|
| 1 | Germany | {"selectedProducts": [{"product": {"size": 2.5, "id": 72}, "quantity": 1},{"product": {"size": 3, "id": 25}, "quantity": 1}]} |
| 2 | Germany | {"selectedProducts": [{"product": {"size": 4, "id": 72}, "quantity": 1},{"product": {"size": 3, "id": 36}, "quantity": 1}]} |
| 3 | Italy | {"selectedProducts": [{"product": {"size": 2.5, "id": 72}, "quantity": 1}]} |
And I've been trying to come up with a SELECT sql query that would allow me to fetch the products' id to be able to study its popularity by country and such, but I haven't been successful at all doing so.
The data column can hold an indeterminate number of products, too. Care to help? I've already tried using the -> and ->> operators in PostgreSQL to no avail, but it might have been me not using them properly