title: Select and count complex sub entities in iOS core data
body: <p>I am doing an app which has a similar database relationships like the image below.</p>
  
  <p><a href="http://i.stack.imgur.com/eSOBG.png" rel="nofollow">http://i.stack.imgur.com/eSOBG.png</a></p>
  
  <p>I am struggling about how to count like how many Employees in each Depart, and select top 5 of them. Can anyone help me out of that?
   Many thanks</p>