珀耳塞福建 发表于 2016-11-14 05:51:16

DB2的with

with temptable(COMCODE,UPPERCOMCODE,Validstatus)
as
(select root.COMCODE,root.UPPERCOMCODE,root.Validstatus
from PRPDCOMPANY root where root.COMCODE=''
union all
select sub.COMCODE,sub.UPPERCOMCODE,sub.Validstatus
from
PRPDCOMPANY sub,
temptable super
where sub.UPPERCOMCODE=super.comcode
and sub.comcode<>super.UpperComCode
and sub.Validstatus = '1')
select COMCODE from temptableORDER BY ComCode
页: [1]
查看完整版本: DB2的with