Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need a query to aggregate rows

 
Max Tomlinson
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi-
I need to accumulate records where the prime record belongs to a particular entity (manager). I need all his/her reporting managers all the way down the chain i.e. managers that report to managers...each record has a supervisor_id reflecting this relationship.
Can I do this with one query by joining to table to itself?
thank you
 
Kai Johnson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might be able to use an IN block. If I understand what you're saying, you're looking for middle managers who report to another manager.

Have you looking into something like:


This will select all managers who have a supervisor_id in that same table, managers.

w3schools SQL IN tutorial
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic