select sum(c.consume_val),v.mobile_num,v.cus_mobile_num,v.card_num,v.car_num,v.old_card_value,
v.card_value,v.recharge_money,v.begin_date,v.end_date,v.is_exist,v.is_seller_del,
v.is_cust_del,v.make_date,s.pic_path,ct.card_category_value
from vip_card_info v,consume_info c,card_pic_store s,seller_card sd,card_category ct
where v.cus_mobile_num = 1
and v.card_id = c.card_id
and v.pic_id = s.pic_id
and v.seller_card_id = sd.seller_card_id
and ct.card_category = sd.card_category
group by v.mobile_num,v.cus_mobile_num,v.card_num,v.car_num,v.old_card_value,
v.card_value,v.recharge_money,v.begin_date,v.end_date,v.is_exist,v.is_seller_del,
v.is_cust_del,v.make_date,s.pic_path,ct.card_category_value
select sum(c.consume_val) val,v.mobile_num,v.cus_mobile_num,v.card_num,v.car_num,v.old_card_value,
v.card_value,v.recharge_money,date_format(v.begin_date,'%Y/%m/%d')beginDate,
date_format(v.end_date,'%Y/%m/%d') endDate,v.is_exist,v.is_seller_del,
v.is_cust_del,date_format(v.make_date,'%Y/%m/%d')makeDate,s.pic_path,ct.card_category_value
from vip_card_info v,consume_info c,card_pic_store s,seller_card sd,card_category ct
where v.cus_mobile_num = 1 and v.card_id = c.card_id and v.pic_id = s.pic_id
and v.seller_card_id = sd.seller_card_id and ct.card_category = sd.card_category
group by v.mobile_num,v.cus_mobile_num,v.card_num,v.car_num,v.old_card_value,
v.card_value,v.recharge_money,v.begin_date,v.end_date,v.is_exist,v.is_seller_del,
v.is_cust_del,v.make_date,s.pic_path,ct.card_category_value
select sum(c.consume_val),v.mobile_num,v.cus_mobile_num,v.card_num,v.car_num,v.old_card_value,
v.card_value,v.recharge_money,v.begin_date,v.end_date,v.is_exist,v.is_seller_del,
v.is_cust_del,v.make_date,s.pic_path,ct.card_category_value
from vip_card_info v,consume_info c,card_pic_store s,seller_card sd,card_category ct
where v.cus_mobile_num = 1
and v.card_id = c.card_id
and v.pic_id = s.pic_id
and v.seller_card_id = sd.seller_card_id
and ct.card_category = sd.card_category
group by v.mobile_num,v.cus_mobile_num,v.card_num,v.car_num,v.old_card_value,
v.card_value,v.recharge_money,v.begin_date,v.end_date,v.is_exist,v.is_seller_del,
v.is_cust_del,v.make_date,s.pic_path,ct.card_category_value
select sum(c.consume_val) val,v.mobile_num,v.cus_mobile_num,v.card_num,v.car_num,v.old_card_value,
v.card_value,v.recharge_money,date_format(v.begin_date,'%Y/%m/%d')beginDate,
date_format(v.end_date,'%Y/%m/%d') endDate,v.is_exist,v.is_seller_del,
v.is_cust_del,date_format(v.make_date,'%Y/%m/%d')makeDate,s.pic_path,ct.card_category_value
from vip_card_info v,consume_info c,card_pic_store s,seller_card sd,card_category ct
where v.cus_mobile_num = 1 and v.card_id = c.card_id and v.pic_id = s.pic_id
and v.seller_card_id = sd.seller_card_id and ct.card_category = sd.card_category
group by v.mobile_num,v.cus_mobile_num,v.card_num,v.car_num,v.old_card_value,
v.card_value,v.recharge_money,v.begin_date,v.end_date,v.is_exist,v.is_seller_del,
v.is_cust_del,v.make_date,s.pic_path,ct.card_category_value
本文通过具体实例展示了如何使用SQL进行复杂的数据联结操作,并重点介绍了针对特定字段进行聚合查询的方法。通过对多个表进行联结查询,实现了对会员卡信息及消费记录的综合统计。
661

被折叠的 条评论
为什么被折叠?



