i'm not sure in SQL query, nut it can achieved from PLSQL,:
declare
str varchar2(10):='12345';
begin
for i in 1..length(str)
loop
dbms_output.put_line(substr(str,1,i));
end loop;
for i in reverse 1..length(str)-1
loop
dbms_output.put_line(substr(str,1,i));
end loop;
end;