ReportingAnalyst
MIS
Hi,
I get the error:
No column was specified for column 4 of 'organization'.
in the following code:
Table structure for Organization is:
Table Structure for Tree is:
I get the error:
No column was specified for column 4 of 'organization'.
in the following code:
Code:
select * from
( select 1 as depth,
emp,
boss,
cast(rtrim(emp) as varchar (400))
from tree
where boss is null
union all
select a.depth + 1 as depth,
b.emp,
b.boss,
cast (a.chain + ', ' + rtrim(b.emp) as varchar(400))
from organization a
inner join tree b
on a.employee = b.boss
) organization
Table structure for Organization is:
Code:
CREATE TABLE Organization
(
depth integer,
employee varchar(20),
boss varchar(20),
chain varchar(20)
)
Table Structure for Tree is:
Code:
create table tree
(emp Char(10) Not Null,
Boss Char(10))