AND (card_content_type IN ('diary') or card_type = 'diary')
)a
group by partition_day,card_content_type,device_id
)t1
LEFT JOIN
(--搜索结果页卡片点击
SELECT cl_id,partition_date
,sum(CASE WHEN card_content_type='service' THEN click_pv END) as service_click_pv
,sum(CASE WHEN card_content_type='neirong' THEN click_pv END) as neirong_click_pv
FROM
(
SELECT partition_date,cl_id,'service' as card_content_type,count(1) as click_pv
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= '{partition_day}'
AND partition_date < '{end_date}'
AND ((action in ('search_result_click_recommend_item','search_result_welfare_click_item')
AND page_name in ('search_result_more','search_result_welfare'))
or (action = 'goto_welfare_detail' AND params ['from'] = 'search_result_welfare_recommend')
or (action = 'on_click_card' AND params['card_content_type'] in ('service') AND page_name in ('search_result_more','search_result_welfare')))
GROUP BY partition_date,cl_id,'service'
UNION ALL
SELECT partition_date,cl_id,'neirong' as card_content_type,count(1) as click_pv
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= '{partition_day}'
AND partition_date < '{end_date}'
AND ((action in ('on_click_topic_card','on_click_diary_card','search_result_click_infomation_item')
AND page_name in ('search_result_more','search_result_diary','search_result_post'))
or (action = 'on_click_card' AND params['card_content_type'] in ('answer','diary') AND page_name in ('search_result_more','search_result_diary','search_result_question_answer')))
GROUP BY partition_date,cl_id,'neirong'
)t2
GROUP BY cl_id,partition_date
)t2
ON t1.partition_day=t2.partition_date AND t1.device_id=t2.cl_id