首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

sql中附加的字段如何进行操作

2012-09-20 
sql中附加的字段怎么进行操作select aaa_id,aaa_name,aaa_value,(select sum(bbb_value) from bbb where b

sql中附加的字段怎么进行操作
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 

热点排行