use dbo; -- Thanks to Wang Chengying, who is behind me DROP TABLE IF EXISTS tmp_ac_t_paas_service_deploy; CREATE TABLE tmp_ac_t_paas_service_deploy SELECT a.*, @rownum := @rownum + 1 `id`, if(@Product = a.`Product` and @service_name = a.service_name, @rank := @rank + 1, @rank := 1) AS `rank`, @Product := a.`Product`, @service_name := a.service_name FROM (SELECT DISTINCT a.name, a.status, a.git_repo, b.`Product`, c.build_no, c.service_name, profile, c.ctime, c.mtime FROM t_paas_service `a` JOIN Git_Product_Service_Mapping `b` ON replace(REPLACE(a.git_repo, 'http://git.jizibaodian.com/', '[email protected]:'), 'https://git.jizibaodian.com/', '[email protected]:') = b.Git_Address_Revised JOIN t_paas_service_deploy `c` ON a.id = c.service_id WHERE a.git_repo <> '' AND c.status <> -1 #AND b.`Product` = 'jizibao' AND profile = 'prod' AND c.ctime >= date_format('2017-12-25', '%Y-%m-%d') ORDER BY b.`Product`, c.service_name, c.ctime) a, (select @rownum := 0, @Product := null, @service_name := null, @rank := 0) b; ALTER TABLE tmp_ac_t_paas_service_deploy ADD PRIMARY KEY (id); ALTER TABLE tmp_ac_t_paas_service_deploy DROP `@Product := a.`Product``; ALTER TABLE tmp_ac_t_paas_service_deploy DROP `@service_name := a.service_name`;
MySQL implements sorting and diagonal movement
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=324739274&siteId=291194637
Recommended
Ranking