L
lee
I need to change the below query such that it extract only those data
which have same upc but different pos.
how would i change the below query to satisfy the below condition
select
fact_auth_sales.primary_distributor_id ,
fact_auth_sales.po_no,
fact_auth_sales.upc,
sum(quantity) as total_quantity
from
fact_auth_sales
left outer join
dim_item on
dim_item.catalog_item_id = fact_auth_sales.item_id
left outer join
dim_reporting_hierarchy on
dim_reporting_hierarchy.pk_rpt_hierarchy_id =
dim_item.fk_rpt_hierarchy_id
where
(
fact_auth_sales.auth_date >= cast ('11/1/09' as date) and
fact_auth_sales.auth_date < cast ('11/16/10' as date)
)
and super_department_name ='gd'
and fact_auth_sales.primary_distributor_id IN ('5928')
group by
fact_auth_sales.po_no,
fact_auth_sales.upc,
fact_auth_sales.primary_distributor_id
which have same upc but different pos.
how would i change the below query to satisfy the below condition
select
fact_auth_sales.primary_distributor_id ,
fact_auth_sales.po_no,
fact_auth_sales.upc,
sum(quantity) as total_quantity
from
fact_auth_sales
left outer join
dim_item on
dim_item.catalog_item_id = fact_auth_sales.item_id
left outer join
dim_reporting_hierarchy on
dim_reporting_hierarchy.pk_rpt_hierarchy_id =
dim_item.fk_rpt_hierarchy_id
where
(
fact_auth_sales.auth_date >= cast ('11/1/09' as date) and
fact_auth_sales.auth_date < cast ('11/16/10' as date)
)
and super_department_name ='gd'
and fact_auth_sales.primary_distributor_id IN ('5928')
group by
fact_auth_sales.po_no,
fact_auth_sales.upc,
fact_auth_sales.primary_distributor_id