cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

query array in SQL

Raymond_Garcia
Contributor II

Hello I have a databricks question I was not able to answer myself

I have this query

select count(*) from table

where object[0].value is not null and object[0].value.value1 = "s"

and created_year = 2022 and created_month = 7 and created_day = 4

you can see object[0] is an array

The question is: how can I query the whole array?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Raymond_Garcia
Contributor II

SELECT count(*)

FROM (

 SELECT explode(mmycolumn)

 FROM table

 WHERE created_year = 2022 and created_month = 7 and created_day = 5

)

WHERE col.field is not null and col.field.field! = "signal"

View solution in original post

1 REPLY 1

Raymond_Garcia
Contributor II

SELECT count(*)

FROM (

 SELECT explode(mmycolumn)

 FROM table

 WHERE created_year = 2022 and created_month = 7 and created_day = 5

)

WHERE col.field is not null and col.field.field! = "signal"

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.