-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathDIM_Customer.sql
38 lines (38 loc) · 1.09 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
/****** Cleansed Customer Table ******/
SELECT
[CustomerKey],
--,[GeographyKey]
--,[CustomerAlternateKey]
--,[Title]
[FirstName] AS [First Name],
--,[MiddleName]
[LastName] AS [Last Name],
[FirstName] + ' ' + [LastName] AS [Full Name], -- Combined First and Last name
--,[NameStyle]
--,[BirthDate]
--,[MaritalStatus]
--,[Suffix]
CASE WHEN [Gender] = 'M' THEN 'Male' WHEN [Gender] = 'F' THEN 'Female' END AS Gender,
--,[EmailAddress]
--,[YearlyIncome]
--,[TotalChildren]
--,[NumberChildrenAtHome]
--,[EnglishEducation]
--,[SpanishEducation]
--,[FrenchEducation]
--,[EnglishOccupation]
--,[SpanishOccupation]
--,[FrenchOccupation]
--,[HouseOwnerFlag]
--,[NumberCarsOwned]
--,[AddressLine1]
--,[AddressLine2]
--,[Phone]
[DateFirstPurchase],
--,[CommuteDistance]
g.city AS [Customer City] -- Joined in [Customer City] column from the Geography table
FROM
[AdventureWorksDW2019].[dbo].[DimCustomer] AS c
LEFT JOIN dbo.DimGeography AS g ON g.GeographyKey = c.GeographyKey -- Joined DimGeography table using PK and FK
ORDER BY
CustomerKey ASC