Skip to content

Instantly share code, notes, and snippets.

@pelaospeed
Forked from William9923/insert-dim-table.sql
Created May 7, 2022 22:20
Show Gist options
  • Save pelaospeed/f32817d69f1f5d2774b8a4c6bb90dc89 to your computer and use it in GitHub Desktop.
Save pelaospeed/f32817d69f1f5d2774b8a4c6bb90dc89 to your computer and use it in GitHub Desktop.

Revisions

  1. @William9923 William9923 created this gist Aug 12, 2021.
    31 changes: 31 additions & 0 deletions insert-dim-table.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    insert into staging.dim_product (
    product_id,
    product_category,
    product_name_length,
    product_description_length,
    product_photos_qty,
    product_weight_g,
    product_length_cm,
    product_height_cm,
    product_width_cm,
    is_current_version
    )
    (select
    product_id,
    CASE
    when product_category is not null then product_category
    else 'OTHER'
    END as product_category,
    product_name_length,
    product_description_length,
    product_photos_qty,
    product_weight_g,
    product_length_cm,
    product_height_cm,
    product_width_cm,
    true as is_current_version
    from live.product
    where product_id not in (select product_id from staging.dim_product));


    -- Notes : Inserting new data on product dimenstion table