Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

need a query to aggregate rows

Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
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
On my planet I'm considered quite beautiful. Thanks to the poetry in this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic