对啊,给 (select count(选择线路) as 报团人数 from 散客登记 where 选择线路='002' group by 选择线路 union all select 报团人数 from 团体登记 where 选择线路='002') 这部分查询出来的内容取个别名,当然你也可以理解为它的作用相当于个临时表
select sum(报团人数) from
(
select count(选择线路) as 报团人数 from 散客登记 where 选择线路='002' group by 选择线路 union all select 报团人数 from 团体登记 where 选择线路='002'
)
t
这里的t 是()中的取的别名 跟 【count(选择线路) as 报团人数】 中的 【as 报团人数】一样