天天看點

解決infobright 的group by 因為NULL值,會出現兩條一樣的結果的問題

原SQL如下:

select date_format(date_sub(current_date(), interval 1 day), '%Y%m%d'),

       a.app_id,

       datediff(date_format(date_sub(current_date(), interval 1 day),

                            '%Y%m%d'),

                date(first_boot_time)),

       datediff(date(op_day_id), date(first_boot_time)),

       '1160201',

       count(distinct imei)

  from  a

 where date_format(first_boot_time, '%Y%m%d') >=

       date_format(date_sub(current_date(), interval 10 day), '%Y%m%d')

 group by a.app_id,

          datediff(date_format(date_sub(current_date(), interval 1 day),

                               '%Y%m%d'),

                   date(first_boot_time)),

          datediff(date(op_day_id), date(first_boot_time));

因表的字段op_day_id有部分為NULL,進行group by後,還會産生兩條一模一樣的值

解決,處理前,先把a表的控制進行處理

繼續閱讀