工作 SQL 快速 查询

1、树形结构查询 ---  查询出级别为1顶级科目树

SELECT accountno as nodeID,
       parentaccountno as parentNodeID,
       (select count(*)
          from gld_005_ent_acct_list
         where parentaccountno = base_table.accountno
           and enterprisecode = 'xs027'),
       accountname as title
  from gld_005_ent_acct_list base_table
 WHERE level = '1'
   and isenabled = 'Y'
   and enterprisecode = 'xs027'
 start with parentaccountno is null
        and enterprisecode = 'xs027'
connect by parentaccountno = prior accountno
       and enterprisecode = prior enterprisecode
 order by accountno


2、查询出 指定商品编码下的所有子项商品编码

select ItemTypeCode
          from pub_item_type_code
         where enterprisecode = 'gxgs'
           and isEnabled = 'Y'
         start with ParentItemTypeCode in ('13', '14')
                and enterprisecode = 'gxgs'
        connect by ParentItemTypeCode = prior ItemTypeCode
               and enterprisecode = prior enterprisecode


 

你可能感兴趣的:(sql,工作,list,table,null)