Subject Re: wrong ordering in WITH RECURSIVE query
Author
Hi,
I've found the reason :-)

create view view_strom_pujcoven
with recursive n (ID_PUJC, NAZEV, FK_BUDOVA, PK_PUJCOVNA, PORADI, FK_UCETNI_JEDNOTKA, JE_UK, SIGLA, JE_ONLINE, ID_BUDOVA_PUV, FK_NADR, JE_EXEMP, uroven, razeni)
as (
  SELECT ID_PUJC, NAZEV, FK_BUDOVA, PK_PUJCOVNA, PORADI, FK_UCETNI_JEDNOTKA, JE_UK,SIGLA, JE_ONLINE, ID_BUDOVA_PUV, FK_NADR, JE_EXEMP, 0, cast('0' as varchar(1024)) FROM def_pujc WHERE fk_nadr is null
  UNION ALL
  SELECT dp.ID_PUJC, dp.NAZEV, dp.FK_BUDOVA, dp.PK_PUJCOVNA, dp.PORADI, dp.FK_UCETNI_JEDNOTKA, dp.JE_UK, dp.SIGLA, dp.JE_ONLINE, dp.ID_BUDOVA_PUV, dp.FK_NADR, dp.JE_EXEMP, n.uroven + 1, cast(n.razeni || '.' || lpad(dp.poradi, 4, '0') as varchar(1024)) FROM def_pujc dp, n WHERE dp.fk_nadr = n.id_pujc
) SELECT * FROM n order by razeni

it generates column RAZENI with content
0
0.0001
0.0001.0001
0.0001.0002
0.0002
0.0002.0010
0.0002.0015
...

It works till the PORADI is less than 10 000 and there is less than 200 levels

Best regards, Tomas