create table public.om_product_view_reseller_business_metrics_db as select distinct --cast(left(ts,4) || '-' || right(left(ts,6),2) || '-' || right(left(ts,8),2) as date) cast(concat(concat(concat(substring(ts,0,5),'-'),concat(substring(ts,5,2),'-')),substring(ts,7,2)) AS date) as App_view_date, profile_objectid as view_object_id,profile_phone,profile_email from clevertap.view_item vi union select distinct cast(concat(concat(concat(substring(ts,0,5),'-'),concat(substring(ts,5,2),'-')),substring(ts,7,2)) AS date) as App_view_date, profile_objectid as view_object_id,profile_phone,profile_email from clevertap.view_cart vi