您好,欢迎访问一九零五行业门户网

PHP如果统计数据库里一个月或者一个礼拜的销售金额

这是数据库,表名:aa_record
drop table if exists pre_record;create table pre_record ( cid smallint(5) unsigned not null default '0', id int(10) unsigned not null auto_increment, #唯一ip name varchar(80) default '', #姓名 mobile varchar(80) default '', #手机号码 products varchar(80) default '', #产品名称 amount varchar(10) default '', #数量/价格 subpay varchar(5) default '', #付款方式 cate varchar(80) default '', #详细地址 courier varchar(5) default '', #选择快递 delivery varchar(5) default '', #发货状态 time datetime default '0000-00-00 00:00:00', #下单时间 primary key (id), key cid_id (cid,id), key cid_dateline (cid)) engine=myisam default charset=utf8 collate=utf8_general_ci;
这个是表格
ip 下单时间 姓名 产品名称 数量/价格 付款方式 发货地址 快递方式 发货状态1 2015-01-01 测试 酱油 1/10 支付宝 上海市 韵达快递 已发货2 2014-12-01 测试1 酱油 1/10 财付通 上海市 申通快递 已发货3 2015-03-01 测试2 酱油 1/10 网银 上海市 韵达快递 已发货4 2015-05-01 测试3 酱油 1/10 财付通 上海市 韵达快递 已发货
php如何来统计这一个月的销量量,或者一个礼拜,比如我筛选  网银付款的,我想把这上个月用网银付款的,又怎么统计
新手,求大神指教
回复讨论(解决方案) 数据表设计的不合理
数量 p_num
单价 p_price
金额 p_money
分别存放一个字段
单价和金额用decimal 类型
时间用时间戳
汇总只需要汇总时间段的金额
select sum(p_money) as  sum_money from pre_record where 时间范围
数据表设计的不合理
数量 p_num
单价 p_price
金额 p_money
分别存放一个字段
单价和金额用decimal 类型
时间用时间戳
汇总只需要汇总时间段的金额
select sum(p_money) as  sum_money from pre_record where 时间范围
如果多个条件如何统计呢,比如:2014-02-02-2014-03-02,用财付通购买的总销售金额
数据表设计的不合理
数量 p_num
单价 p_price
金额 p_money
分别存放一个字段
单价和金额用decimal 类型
时间用时间戳
汇总只需要汇总时间段的金额
select sum(p_money) as  sum_money from pre_record where 时间范围
没问题了,谢谢
其它类似信息

推荐信息