
Answer-first summary for fast verification
Answer: SELECT department_id,FILTER(employees, e -> e.employee_salary > 500000) as employees_with_high_salary FROM company;
The correct answer utilizes the `FILTER` higher-order function, which filters an array based on a given lambda function. In this case, it checks each employee's salary to see if it exceeds USD 500,000. The syntax involves specifying the array (`employees`), an iterator variable (`e`), and the condition (`e.employee_salary > 500000`). The result is a new column, `employees_with_high_salary`, containing only those employees who meet the criteria. This approach efficiently isolates high earners within each department.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
As a data engineer, your task is to identify employees earning more than USD 500,000 within each department of the company. Given the schema of the company table, which SQL snippet accomplishes this?
A
SELECT department_id,TRANSFORM(employees, e -> e.employee_salary > 500000) as employees_with_high_salary FROM company;
B
SELECT department_id,FETCH(employees, e -> e.employee_salary > 500000) as employees_with_high_salary FROM company;
C
SELECT department_id,EXIST(employees, e -> e.employee_salary > 500000) as employees_with_high_salary FROM company;
D
SELECT department_id,REDUCE(employees, e -> e.employee_salary > 500000) as employees_with_high_salary FROM company;
E
SELECT department_id,FILTER(employees, e -> e.employee_salary > 500000) as employees_with_high_salary FROM company;