doris icon indicating copy to clipboard operation
doris copied to clipboard

使用date_format后的字段进行inner join时,查询结果不正确

Open MatioYoshitoki opened this issue 5 years ago • 1 comments

select date_format(a.event_time, '%Y-%m-%d') recharge_date, a.user_id, b.event_time, a.event_time from ods_event_recharge a inner join ods_event_user_register b on a.user_id = b.user_id and a.event_date_id = date_format(b.event_time, '%Y%m%d');

select date_format(a.event_time, '%Y-%m-%d') recharge_date, a.user_id, b.event_time, a.event_time from ods_event_recharge a inner join ods_event_user_register b on a.user_id = b.user_id and date_format(a.event_time, '%Y%m%d') = date_format(b.event_time, '%Y%m%d');

这2个语句中第一个的a.event_date_id为一个int值,内容相当于%Y%m%d格式的日期,比如20210526,a.event_time与b.event_time均为datetime类型。2条语句的查询结果差别巨大。

MatioYoshitoki avatar May 26 '21 01:05 MatioYoshitoki

Hi,Could you please give more detail info of this problem:

  1. which version you were tested
  2. How to reproduce:table struct,data of table

HappenLee avatar May 27 '21 04:05 HappenLee