【求助】SQL两个表中的数据做运算,为什么不是最终运算结果?
select a.tmp_warehouse as ack,count(a.tmp_num) as kctm,sum(a.tmp_price_t) as kczj from tmp_kcjl a group by a.tmp_warehouse
select b.tmp_warehouse as bck,count(b.tmp_num) as cktm,sum(b.tmp_price_t) as ckzj from tmp_ckmx b group by b.tmp_warehouse
有a、b两个表,先从两个表中提取相关字段后以tmp_warehouse汇总,然后把汇总后结果做除法运算,该怎么写语句?
a.ack as ck,(b.cktm/(a.kctm+b.cktm)) as tmzzl,(b.ckzj/(a.kczj+b.ckzj)) as jezzl,((b.cktm/(a.kctm+bb.cktm))+(b.ckzj/(a.kczj+bb.ckzj))) as hjzzl
[此贴子已经被作者于2021-11-20 20:30编辑过]