Databricks Certified Data Analyst Associate — Question 16

A data analyst has created a user-defined function using the following line of code:
CREATE FUNCTION price(spend DOUBLE, units DOUBLE)

RETURNS DOUBLE -
RETURN spend / units;
Which of the following code blocks can be used to apply this function to the customer_spend and customer_units columns of the table customer_summary to create column customer_price?

Answer options

Correct answer: E

Explanation

The correct answer is E because it correctly calls the user-defined function price with the appropriate parameters and assigns the result to the customer_price column. Options A and B are syntactically incorrect as they do not properly invoke the function or use the correct SQL syntax. Option C incorrectly applies the function keyword, and D incorrectly uses the double keyword, which is unnecessary.