数据库日期格式化(事例)

本文通过具体实例展示了如何使用SQL进行复杂的数据联结操作,并重点介绍了针对特定字段进行聚合查询的方法。通过对多个表进行联结查询,实现了对会员卡信息及消费记录的综合统计。



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
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值