I hope you’re doing good!
I’m Jacques and I’m taking the ‘SQL for Data Analyitcs’ course !
I’m struggling again with the ‘Sales Search and Analysis’ part, especially with the JSON and JSONB functions. Has someone already done it?
I’m trying to create a searchable materialized table but I cannot create a specifical column to have the customer_id. I tried to use function "JSONB_ARRAY_ELEMENTS to kinda put away an element as a column, but I don’t really know how to do it properly… Can someone give me a hand? Here is my code below:
create materialized view searchable as ( select cjsonb_array_elements(customer_json -> 'customer_id') as customer_id , customer_json , to_tsvector('english', customer_json::text) as search_vector from customer_sales limit 20; );
Thank you very much for your help!