select sum (维修费用) from 设备表 t1,
(
select 设备编码 from 设备表
CONNECT BY PRIOR 设备编码 = 父设备编码 
START WITH  设备编码='A'
) t2
where t1.设备编码=t2.设备编码 and t2.设备编码<>'A'

解决方案 »

  1.   

    select sum(维修费用) from 设备表 start with 设备编码='A' 
              connect by prior 设备编码 = 父设备编码;
      

  2.   

    CONNECT BY
    语法:
    SELECT sql_expn FROM [user.]table WHERE where_condition
    CONNECT BY [PRIOR] expn = [PRIOR] expn
    START WITH expn = expn
    ORDER BY expn
    变量:
    sql_expn:有效的SQL表达式
    user:表的主人
    table:  SELECT的表
    where_condition:SELECT的WHERE条件
    expn:任意有效的表达式
    例子:
    SQL
    SELECT employee_name, department_name FROM employee
    CONNECT BY emp_no = PRIOR department_no
    ORDER BY department_no;.