Autor Wiadomość
ghdhair100
PostWysłany: Śro 9:39, 02 Mar 2011    Temat postu: 多表查询

表A是会员表,B是消费记录表,D是积分消费表
select a.id as '会员ID',a.member_num as '会员卡号',a.member_name as '会员姓名',a.mobile as '会员手机号',
sum(b.v_money) as '会员总积分',isnull((select sum(d.v_money) from l_vmoney_order d where a.id=d.member_id
group by d.member_id),0) as '会员已消费积分',sum(b.v_money)-isnull((select sum(d.v_money) from l_vmoney_order d where a.id=d.member_id
group by d.member_id),0) as '会员剩余积分'
from i_member a,l_order b where a.id=b.member_id
group by a.id,a.member_num,a.member_name,a.mobile
order by 会员总积分
Many years ago there lived an Emperor who was so exceedingly fond of fine new clothes that he spent vast sums of money on dress. To him clothes meant more than anything else in the world. He took no interes
related links:


销售――至理名言

Powered by phpBB © 2001,2002 phpBB Group