select table_a.项目名称 table_b.金额 table_c.送红包 table_c.吃饭
from table_a,table_b,table_c
where table_a.项目编号=table_b.项目编号 and table.产品编号=table_c.产品编号
ok le
from table_a,table_b,table_c
where table_a.项目编号=table_b.项目编号 and table.产品编号=table_c.产品编号
ok le
(select 金额 from table_C where 产品编号=B.产品编号 and 名称='送红包' ) as 送红包,
(select 金额 from table_C where 产品编号=B.产品编号 and 名称='吃饭') as 吃饭
from
table_c C left join table_b B on C.产品编号=B.产品编号
left join table_a A on B.项目编号=A.项目编号
[送红包]=sum(case when 名称='送红包' then 金额 else 0 end),
[吃饭]=sum(case when 名称='吃饭' then 金额 else 0 end),
from table_a a,table_b b,table_c c
where a.项目编号=b.项目编号 and a.项目编号=right(c.产品编号,1)
group by a.项目编号,b.金额
lxd99423(苹果) ( )
的方法好
to:
chiwei(水手)
可以得到结果,但是很慢了
to:
chenqianlong(443)
我的那个[吃红包],[吃饭]是值,而不是字段!