我有以下脚本:
SELECT *
FROM (
SELECT distinct web_product_source_id, recipe_id, cos_score,
row_number() over (partition by web_product_source_id order by cos_score desc) as rnk
FROM (
SELECT web_product_source_id, recipe_id, max(cos_score) cos_score
FROM edw_sandbox.combined_with_product_details_ouput_cleaned
WHERE web_supercat_source_id = 'cookware'
GROUP BY 1,2
) a
) b
WHERE rnk <= 20
ORDER BY web_product_source_id, rnk;
我想在“ WHERE”语句中添加if else语句。如果web_product_source_id id包含以下任何一项(“炊具”,“设置”等),我希望数据排在前20名或前40名
Sudo代码:
if 'set' or 'cookware' in web_product_source_id id: pull top 40 ranks
else: pull top 20 ranks and cos_score >= .7