select 字段里嵌套select 用法问题

select o.username,
o.uagent,
o.cscode,
o.product,
(SELECT min(time.createTime)
FROM (select t.createtime
from dataintegration t
where t.username = o.username

union all
select t.user_create_time
from diuser t
where t.user_name = o.username) time) createTime
from dataintegration o

            里面会报o.username无效,到底是什么问题?怎么解决?o表里一定有username字段,拜托大家

select t.createtime
from dataintegration t
where t.username = o.username

union all
select t.user_create_time
from diuser t
where t.user_name = o.username
这段是最底层(第三层),它的外面是自定义的TIME表(第二层),而O表在TIME表外面(第一层),where条件不能跨层取。
如果你一定想这么写的话,把O表放到最底层去,或者
select o.username,
o.uagent,
o.cscode,
o.product,
min( createTime)
from(
select o.username,
o.uagent,
o.cscode,
o.product,
(select t.createtime
from dataintegration t
where t.username = o.username

       union all
       select t.user_create_time
         from diuser t
       where t.user_name = o.username) createTime

from dataintegration o
)