Read Using SQL Snippets before using any of this site's code or techniques on your own systems.

Hierarchical Selective Expansion

The term "selective expansion" describes a hierarchical query where all the rows at, above, and below a target item are returned. For example, given a data set that looks like this:

PADDED_KEY
---------------
a
  a.a
  a.b
b
  b.a
  b.b
    b.b.a
  b.c
    b.c.a
    b.c.b
    b.c.c
      b.c.c.a
      b.c.c.b
      b.c.c.c
 

a selective expansion of a target item like "b.c.c" would give us the following rows.

PADDED_KEY
---------------
b
  b.c
    b.c.c
      b.c.c.a
      b.c.c.b
      b.c.c.c
 

The tutorials in this section describe various methods for performing a selective expansion. If you are not familiar with hierarchical queries you should review SQL Features Tutorials: Hierarchical Data before proceeding.