By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
✓
✓
| paths |
|---|
| file1.txt |
| subdir/file2.txt |
| subdir/file3.txt |
| subdir/deeper/file4.txt |
| subdir/another/deep/dir/file5.txt |
| paths |
|---|
| subdir/file2.txt |
| subdir/file3.txt |
| subdir/deeper/file4.txt |
| subdir/another/deep/dir/file5.txt |
| path |
|---|
| file2.txt |
| file3.txt |
| deeper/file4.txt |
| another/deep/dir/file5.txt |
| SUBSTR ( path, 1, CASE INSTR(path, '/') WHEN 0 THEN LENGTH(path) ELSE INSTR(path, '/') END ) |
|---|
| file2.txt |
| file3.txt |
| deeper/ |
| another/ |