QuestionQ48

VerifiedData Modeling with Databricks SQL

A data analyst is working with the following my_table table:

| customer_name | dollars_spent |

|---|---|

| Hex Sprockets | [125.34, 100.15, 9003.99] |

| Dented Fenders | [16.99, 200.85, 33.49, 88.17] |

The analyst now wants to divide every value in the dollars_spent array by 100 to express spending in hundreds of dollars, using this code block:

SELECT  
  customer_name,  
  _______  
FROM my_table  

Which line of code can fill in the blank so that the code block successfully accomplishes the task?

Explanation

Databricks SQL transform applies a lambda expression to each element of an array. The lambda value -> value / 100 divides each dollars_spent element by 100, and AS hundreds_spent assigns the resulting array its required output name.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!