select distinct ttt.PRJ,ttt.CCTR from (
select distinct
substring(gl06001,23,6) CCTR, substring(gl06001,34,3) PRJ--, '08' as Entity
from [cnbj1scala01].[ScalaDB_Trading].[dbo].GL060811
where substring(gl06001,34,3)!='' and substring(gl06001,23,6)!=''
--order by CCTR ,PRJ
union all
select distinct
substring(gl06001,23,6) CCTR, substring(gl06001,34,3) PRJ--, '03' as Entity
from [cnbj1scala01].[ScalaDB_Trading].[dbo].GL060311
where substring(gl06001,34,3)!='' and substring(gl06001,23,6)!=''
--order by CCTR ,PRJ
) as ttt
where exists (
select tt.CCTR ,Count(tt.CCTR ) from (
select distinct t.CCTR ,t.PRJ from (
select distinct
substring(gl06001,23,6) CCTR, substring(gl06001,34,3) PRJ--, '08' as Entity
from [cnbj1scala01].[ScalaDB_Trading].[dbo].GL060811
where substring(gl06001,34,3)!='' and substring(gl06001,23,6)!=''
--order by CCTR ,PRJ
union all
select distinct
substring(gl06001,23,6) CCTR, substring(gl06001,34,3) PRJ--, '03' as Entity
from [cnbj1scala01].[ScalaDB_Trading].[dbo].GL060311
where substring(gl06001,34,3)!='' and substring(gl06001,23,6)!=''
--order by CCTR ,PRJ
) as t
) as tt
where ttt.CCTR =tt.CCTR
group by tt.CCTR
having COUNT(tt.CCTR )>=2
)