-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDim_Customer.sql
38 lines (38 loc) · 1.05 KB
/
Dim_Customer.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
-- Cleaned Dim_Customers Table
SELECT
c.[CustomerKey],
--[GeographyKey]
--[CustomerAlternateKey]
--[Title]
c.[FirstName] AS [First Name],
--[MiddleName]
c.[LastName] AS [Last Name],
c.FirstName + ' ' + LastName AS [Full Name],
--[NameStyle]
--[BirthDate]
--[MaritalStatus]
--[Suffix]
CASE c.[Gender] WHEN 'M' THEN 'Male' WHEN 'F' THEN 'Female' END AS Gender,
--[EmailAddress]
--[YearlyIncome]
--[TotalChildren]
--[NumberChildrenAtHome]
--[EnglishEducation]
--[SpanishEducation]
--[FrenchEducation]
--[EnglishOccupation]
--[SpanishOccupation]
--[FrenchOccupation]
--[HouseOwnerFlag]
--[NumberCarsOwned]
--[AddressLine1]
--[AddressLine2]
--[Phone]
c.[DateFirstPurchase],
--[CommuteDistance]
g.City AS [Customer City] -- Joined Customer City from Geography Table
FROM
[AdventureWorksDW2019].[dbo].[DimCustomer] AS c
LEFT JOIN [AdventureWorksDW2019].[dbo].[DimGeography] AS g ON g.GeographyKey = c.GeographyKey
ORDER BY
CustomerKey ASC --Ordered list by CustomerKey