What is the average number of working horses of farms with more than 5000 total number of horses?
return farms ;return horses on  #1 ;return number of  #2 for each  #1 ;return #1 where #3 is  higher than 5000 ;return horses on  #4 ;return #5 that  are  working ;return number of  #6 ;return average of  #7
['select', 'project', 'group', 'comparative', 'project', 'filter', 'aggregate', 'aggregate']