55.0k views
1 vote
Fill in the below blank to get the students enrolled in less than 3 courses from array column students

SELECT
faculty_id,
students,
___________ AS few_courses_students
FROM faculties
a) TRANSFORM (students, total_courses < 3)
b) TRANSFORM (students, i -> i.total_courses < 3)
c) FILTER (students, total_courses < 3)
d) FILTER (students, i -> i.total_courses < 3)
e) CASE WHEN students.total_courses < 3 THEN students ELSE NULL END

User Userv
by
9.0k points

1 Answer

3 votes

Final answer:

The correct answer is d) FILTER (students, i -> i.total_courses < 3). In this query, the FILTER function is used to select the students who are enrolled in less than 3 courses.

Step-by-step explanation:

The correct answer is d) FILTER (students, i -> i.total_courses < 3).

In this query, we want to select the faculty_id and students columns from the faculties table and also a new column called few_courses_students, which represents the students who are enrolled in less than 3 courses.

To accomplish this, we can use the FILTER function to filter the students based on a condition. In this case, the condition is i.total_courses < 3, which checks if the total_courses value of the student is less than 3.

Here is an example of how the query would look like:

SELECT faculty_id, students, FILTER (students, i -> i.total_courses < 3) AS few_courses_students FROM faculties;

User Ramanathan
by
7.5k points