June 10, 2015 at 2:46 pm
I created a query that got the following result. But I expect to get the structure like, care_nbr, cust_nbr,legal_name, address_type=physical address, addr_line_1, addr_line_2, address_type-primary address, ddr_line_1, addr_line_2. That means I only need primary and physical address, and expect them to show in a row to each care_nbr. How to perform that? Thank you.:-)
CARE_Nbr||Cust_Nbr||Legal_Name||||||| Address_Tpye |||Addr_Line_1 ||||||||||||||||Addr_Line_2
99000001||004554||Mac Marketing, LLC||Billing Address||210 Parktowne Blvd Ste. 1||NULL
99000001||004554||Mac Marketing, LLC||Mailing Address||210 Parktowne Blvd Ste. 1||NULL
99000001||004554||Mac Marketing, LLC||Primary Address||210 Parktowne Blvd Ste. 1||NULL
99000001||004554||Mac Marketing, LLC||Physical Address||210 Parktowne Blvd Suite 1||NULL
My script is here, and the sample result is attached. How should I modify this query to get my expected result?
select a.CARE_Number,
a.Customer_Nbr_Txt,
a.Customer_Type_Txt,
a.Legal_Name_Txt,
c.Address_Type_Txt,c.Address_Line_1_Txt,c.Address_Line_2_Txt,
a.Customer_Status_Txt,
a.Legal_Entity_Type_Txt,
a.Business_Unit_Txt
FROM dw_mart.dbo.DimCustomer a
join DW_ODS.dbo.Customer_Header_Tbl b
on a.Customer_Nbr_Txt=b.Customer_Nbr_Txt
join dw_ods.dbo.Customer_Address_Tbl c
on b.Cust_Nbr_Key=c.Cust_Nbr_Key
where (a.Legal_Name_Txt like '% LLC%'
or a.Legal_Name_Txt like '%L.L.C%'
or a.Legal_Name_Txt like '%L.C%')
and a.Legal_Entity_Struct_Txt not like '%Limited Liability%'
AND a.Current_Row_Flag='Y'
and a.Source_System_Code_Txt='WMS'
order by 1
June 10, 2015 at 9:05 pm
I understand that you would really like some help, but please try not to start multiple threads for the same request.
It's much easier for us to help you if all the communication is one place!
The original thread is http://www.sqlservercentral.com/Forums/Topic1693390-391-1.aspx
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply