• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

need a query to aggregate rows

 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic