-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDIM_CUSTOMER.sql
More file actions
39 lines (39 loc) · 1.13 KB
/
DIM_CUSTOMER.sql
File metadata and controls
39 lines (39 loc) · 1.13 KB
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
39
--Cleansed DimCustomer Table
SELECT
c.[CustomerKey] AS CustomerKey,
--,[GeographyKey]
--,[CustomerAlternateKey]
--,[Title]
c.[FirstName] AS FirstName,
--,[MiddleName]
c.[LastName] AS LastName,
c.FirstName + ' ' + LastName AS FullName,
--Combined First and Last 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] AS DateFirstPurchase,
--,[CommuteDistance]
g.City AS CustomerCity --Joined in Customer City from Geography Table
FROM
[AdventureWorksDW2019].[dbo].[DimCustomer] AS c
Left join [AdventureWorksDW2019].[dbo].[DimGeography] AS g on c.GeographyKey = g.GeographyKey
Order by
CustomerKey ASC -- Ordered List by CustomerKey