mysql 排序表

-- 快件表 statistics-job无写权限
-- 方案一 express-service新增dubbo接口
-- 方案二 statistics-job 配置 yg_express写库
insert into  express_order_stor_temp_source_statistics(id,receive_tel,source,num)
SELECT
	@id :=@id + 1,
	t.*
FROM
	(
		SELECT
			t.receive_tel,
			t.source,
			count(1)
		FROM
			express_order_stor t
		WHERE
			t.`status` = 7
		AND t.source IN (1, 2)
		AND t.update_time >= '2019-03-01'
		AND t.update_time < '2019-04-01'
		GROUP BY
			t.receive_tel,
			t.source
		ORDER BY
			count(1) DESC
	) t,
	(SELECT @id := 0) f;

CREATE TABLE `express_order_stor_temp_source_statistics` (
  `id` int(11) NOT NULL COMMENT 'id',
  `receive_tel` varchar(50) COMMENT '收件人',
  `source` tinyint(2) COMMENT '订单来源:1:菜鸟 2:拼多多',
  `num` int(8) COMMENT '数量',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='快件历史订单临时来源统计表';

select * from express_order_stor_temp_source_statistics where id>1500000 limit 1000;

  

上一篇:java 手机号本地验证归属地


下一篇:【Hibernate学习笔记-3】在Spring下整合Hibernate时, 关于sessionFactory的类型的说明