the best thing for the questioner to do would be to say what database is being used ...
because ... this update statement will not work for sql server
next thing would be to supply decent data example
for sqlserver:
update yourtable
set childnum = c.num_children
from yourtable t1,
(select parentno, count(*) num_children from yourtable group by parentno) c on t1.idno = c.parentno
for oracle:
use above statement :)
Main Topics
Browse All Topics





by: petr_hlucinPosted on 2008-12-27 at 09:51:38ID: 23248936
I'm not sure it is possible to achieve this using 1 update statement. If it is it should be the update statement attached.
What you'll have to do is to select all these counts (see select statement attached), create more update statements as a scripts and execute this script.
Select allOpen in new window