Advertisement
Pandaaaa906

Untitled

Dec 21st, 2022
1,115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2.  
  3. t.id,
  4. t.brand_name,
  5. t.cat_no,
  6. t.en_name,
  7. t.cn_name,
  8. t.cas,
  9. t.catalog_array,
  10. case when 'tanmo' = any(tmp.brand_arr) then '有'
  11. else '无' end "坛墨官网是否有",
  12. case when 'anpel' = any(tmp.brand_arr) then '有'
  13. else '无' end "安谱官网是否有",
  14. -- TODO 海岸鸿蒙 中国,中检所
  15. tmp.brand_arr,
  16. 匹配规则
  17.  
  18. FROM tmp."202212危险品匹配" t
  19.  
  20. LEFT JOIN (
  21.     SELECT
  22.     t.id,
  23.     ARRAY_AGG(distinct prd.brand) brand_arr,
  24.     array_agg(distinct prd.cat_no) cat_no_arr,
  25.     array_agg(distinct case
  26.     when t.cas != 'N/A' and t.cas = prd.cas then 'cas'
  27.     when t.cn_name = prd.chs_name then '中文名'
  28.     when t.en_name = prd.en_name then '英文名'
  29.     else null end) "匹配规则"
  30.  
  31.     FROM tmp."202212危险品匹配" t
  32.  
  33.     INNER JOIN rawdata prd
  34.     ON prd.brand != 'cato'
  35.     AND (
  36.         t.en_name = prd.en_name
  37.         OR t.cn_name = prd.chs_name
  38.         OR (t.cas != 'N/A' and t.cas = prd.cas)
  39.     )
  40.     GROUP BY t.id
  41.    
  42. ) tmp
  43. ON tmp.id = t.id
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement