1:业务--一张表 对于一个字段为空的话 则去取另一张表 取此字段
select t.label_code,
case when t.label_cover is null then d.cover_rate else t.label_cover end,
case when t.label_active is null then d.actv_cover_rate else t.label_active end,
t.*
from hs_label t
LEFT JOIN (SELECT
c1.label_cn_name,
c1.cover_rate,
c1.actv_cover_rate
FROM
hs_label_gds c1
WHERE
c1.date = (
SELECT
MAX(DATE(date))
FROM
hs_label_gds
)) d on t.label_name=d.label_cn_name
select t.label_code,
case when t.label_cover is null then d.cover_rate else t.label_cover end,
case when t.label_active is null then d.actv_cover_rate else t.label_active end,
t.*
from hs_label t
LEFT JOIN (SELECT
c1.label_cn_name,
c1.cover_rate,
c1.actv_cover_rate
FROM
hs_label_gds c1
WHERE
c1.date = (
SELECT
MAX(DATE(date))
FROM
hs_label_gds
)) d on t.label_name=d.label_cn_name