sql-备忘-指更新为null的记录

SELECT
  serial_no,
  MAX( setup_date ) setup_date,
  MAX( liquidate_date ) liquidate_date,
  MAX( expire_date ) expire_date 
FROM
  (
  SELECT
    t1.serial_no,
    IFNULL( t1.setup_date, 0 ) setup_date,
    IFNULL( t1.clear_date, 0 ) liquidate_date,
    IFNULL( t1.expire_date, 0 ) expire_date 
  FROM
    sam_saleproject_copy1 t1 UNION ALL
  SELECT
    t2.serial_no,
    1 setup_date,
    1 liquidate_date,
    1 expire_date 
  FROM
    sam_saleproject_copy1 t2 
  ) t3 
GROUP BY
  serial_no

posted on 2020-11-19 17:31  caffebabe  阅读(49)  评论(0编辑  收藏  举报