I'm working with a strangely designed (let's call it suboptimal) Oracle database. One issue is that one of the columns contains 2 different types of text data: "header" data and "content" data. Kind of like this:
| id | text |
|---|---|
| 1 | Header 1: |
| 2 | abc |
| 3 | def |
| 4 | Header 2: |
| 5 | ghi |
| 6 | jkl |
| 7 | mno |
| 8 | Header 3: |
| 9 | pqr |
If possible, I need to construct SQL that essentially returns the "Header" rows as control breaks for the "content" rows to get these results:
Header 1: abc
Header 1: def
Header 2: ghi
Header 2: jkl
Header 2: mno
Header 3: pqr
The id values are sequential, but the content for each header can span an arbitrary number of rows. So the only clue to which "header" applies to each "content" row is that it's the previous Header seen (max id value where text like '%Header% < id of current row).