select aaa_id,aaa_name,aaa_value,(select sum(bbb_value) from bbb where bbb_id=aaa_reid) as bbb_value,aaa_value/bbb_value as ccc from aaa
aaa_value/bbb_value as ccc 这个地方无法使用 bbb_value
应该怎么才能使用这个附加的字段呢
------解决方案--------------------
- SQL code
--不能直接使用,换个方式select aaa_id,aaa_name,aaa_value,bbb_value,aaa_value/bbb_value as ccc from( select aaa_id,aaa_name,aaa_value,(select sum(bbb_value) from bbb where bbb_id=aaa_reid) as bbb_value from aaa ) t--orselect aaa_id,aaa_name,aaa_value,(select sum(bbb_value) from bbb where bbb_id=aaa_reid) as bbb_value,aaa_value/(select sum(bbb_value) from bbb where bbb_id=aaa_reid) as ccc from aaa