-
Notifications
You must be signed in to change notification settings - Fork 0
/
QUERY-DIM-CustomerTable-Cleansed.sql
44 lines (38 loc) · 1.13 KB
/
QUERY-DIM-CustomerTable-Cleansed.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
39
40
41
42
43
44
-- CLEANSED DIM_CUSTOMER TABLE
SELECT c.CustomerKey AS [Customer Key]
--,[GeographyKey]
--,[CustomerAlternateKey]
--,[Title]
,c.FirstName AS [First Name]
--,[MiddleName]
,c.LastName AS [Last Name]
,c.LastName + ' ' + c.FirstName AS [Full Name]
--,[NameStyle]
--,[BirthDate]
--,[MaritalStatus]
--,[Suffix]
,CASE c.Gender WHEN 'M' THEN 'Male' WHEN 'F' THEN 'Female' END AS [Gender]
,c.gender AS [Test]
--,[EmailAddress]
--,[YearlyIncome]
--,[TotalChildren]
--,[NumberChildrenAtHome]
--,[EnglishEducation]
-- ,[SpanishEducation]
--,[FrenchEducation]
-- ,[EnglishOccupation]
--,[SpanishOccupation]
--,[FrenchOccupation]
--,[HouseOwnerFlag]
--,[NumberCarsOwned]
--,[AddressLine1]
--,[AddressLine2]
--,[Phone]
,c.DateFirstPurchase AS [Date First Purchase],
--,[CommuteDistance]
g.city AS [Customer City]
FROM
[AdventureWorksDW2022].[dbo].[DimCustomer] as c
left join [AdventureWorksDW2022].[dbo].[DimGeography] as g ON g.geographykey=c.geographykey
ORDER BY
CustomerKey ASC