Advertisement
Pandaaaa906

Untitled

Aug 17th, 2022
1,278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. UPDATE "public"."productpackage" pkg
  2. set package = tmp.package
  3. -- purity = substring(package from '\(([^)]+)\)')
  4. FROM (
  5. with t as (
  6.  
  7. SELECT
  8. id,
  9. cat_no,
  10. package old_package,
  11. regexp_replace(trim(substring(package from '(.+)(\([^)]+\))?')),'(?<=\d) (?=[a-zμ])','', 'g') package,
  12. substring(package from '\(([^)]+)\)') purity,
  13. row_number() over(partition by cat_no, regexp_replace(trim(substring(package from '(.+)(\([^)]+\))?')),'(?<=\d) (?=[a-zμ])','') ORDER BY id desc) r
  14. FROM "public"."productpackage"
  15.  
  16. WHERE "brand" = 'mce'
  17. AND "package" LIKE '%(%'
  18. )
  19.  
  20. SELECT
  21. *
  22. FROM t
  23. where r=1
  24.  
  25.  
  26. ) tmp
  27. where pkg.id = tmp.id
  28.  
  29.  
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement