SQL: flattening a hierarchy

Original text of this message