select * from tbl_name procedure analyse();

select * from tbl_name procedure analyse(16,256);

创建客户每天的消费记录:

Create Table: CREATE TABLE `session` (
`cust_id` varchar(10) DEFAULT NULL,
`cust_amount` decimal(16,2) DEFAULT NULL,
`cust_date` date DEFAULT NULL,
`cust_ip` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

最近一周客户消费的总金额和近一周不同时段用户的消费总金额

select sum(cust_amount) from session where cust_date>adddate(now(),-7);

创建中间临时表

Create Table: CREATE TABLE `tmp_session` (
`cust_id` varchar(10) DEFAULT NULL,
`cust_amount` decimal(16,2) DEFAULT NULL,
`cust_date` date DEFAULT NULL,
`cust_ip` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8

insert into session values(3,300,'2013-1-7','192.168.1.1');

相关文章:

  • 2022-01-04
  • 2021-12-13
  • 2021-09-28
  • 2022-12-23
  • 2021-10-04
  • 2021-04-27
  • 2021-04-21
猜你喜欢
  • 2021-10-07
  • 2021-09-08
  • 2021-10-15
  • 2021-09-03
  • 2021-07-01
  • 2021-06-06
相关资源
相似解决方案