×

Loading...

Try this hierarchical query.

Why not try the following SQL query.

SELECT LPAD(\" \", 2*(LEVEL-1))||column1, column2, ...
FROM table_name
WHERE column1 like \"A%\"
START WITH column1 = \"A\"
CONNECT BY prior column1 = substr(column1, 1, length(column1) - 1);

Result like:

column1 column2 ...
------------ ------------
A
AA
AAA
AAB
AB


The \"LEVEL\", \"START WITH\", \"prior\" and \"CONNECT BY\" are the Oracle key words

Note: LPAD(\" \"), \"A%\", \"A\" , the \" should be replaced by DAN1 YIN3 HAO4.
Report

Replies, comments and Discussions: