I'm trying to write an SQL Statement that needs to loop through a list of departments, kind of like a For Each.
Heres what I have so far.
SELECT DISTINCT AVG(salary),assigned->name
FROM edu_ucla_cs241_termproj_schema.InstructorImpl
WHERE assigned->name = 'Anthropology'
This will give me a table of Avg Salary Department 90.15 Anthropology
However, I want to loop through each department. Can I make this query take a variable and loop through each department name?