Skip to content
Advertisement

How to print pattern output in Oracle’s SQL

I have a table with below data

Table : emp

name
A
B
C
D

Expected Output :

names
A
AB
ABC
ABCD

I only know how to print data in horizontal form

Not sure how to cut the horizontal and get expected output

Advertisement

Answer

You can use a hierarchical query:

Which, for the sample data:

Outputs:

NAMES
A
AB
ABC
ABCD

db<>fiddle here

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement