【Mysql】根據時間去除重複數據

SELECT  a.project_id,a.user_id,a.app_version,a.src_system,a.channel,a.thedate
FROM rpt_innoreport_luckyday.dnu_user_id a    
WHERE a.thedate='2019-04-14' and a.app_version = 
(SELECT  MAX(b.app_version)  FROM rpt_innoreport_luckyday.dnu_user_id b  
 WHERE a.user_id = b.user_id and a.project_id=b.project_id
 and a.src_system=b.src_system and a.channel=b.channel)    ;

建表語句以下:app

CREATE TABLE `testdau` (
  `project_id` varchar(11) DEFAULT NULL,
  `user_id` varchar(11) DEFAULT NULL,
  `app_version` varchar(255) DEFAULT NULL,
  `src_system` varchar(11) DEFAULT NULL,
  `channel` varchar(11) DEFAULT NULL,
  `thedate` varchar(11) DEFAULT NULL,
  `time` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

 

 

xiaomin重複,根據版本app_version去重,去版本大的spa

 

相關文章
相關標籤/搜索