-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommunity.Product_Invite_Conversion.sql
More file actions
69 lines (65 loc) · 2.33 KB
/
Copy pathCommunity.Product_Invite_Conversion.sql
File metadata and controls
69 lines (65 loc) · 2.33 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
--====================================================================================================================================================
--= Invite Conversion for Invites Sent to Non-Members
-- Query time: 2min19sec
--====================================================================================================================================================
-- Drop the current table in the datalake
DROP TABLE community.Product_Invite_Conversion
SELECT OpenIdSender,
EmailAddressRetriever,
MonthYear,
InviteType,
CASE WHEN InviteDate < SignupDate OR SignupDate IS NULL THEN 1 ELSE 0 END AS InviteToNonMember,
CASE WHEN InviteDate < SignupDate AND datediff(day, InviteDate, SignupDate) <= 30 AND NOT(SignupDate IS NULL) THEN 1 ELSE 0 END InviteToNonMemberLeadingToSignup
INTO community.Product_Invite_Conversion
FROM
(
SELECT OpenIdSender,
EmailAddressRetriever,
InviteDate,
InviteType,
/*
-- If the created date of the company is not set in platform analytics, this value will be NULL (4 cases known on 20180525)
CASE
WHEN CompanyType IS NULL
THEN 'Other'
ELSE CompanyType
END AS CompanyType,
*/
dateadd(month,datediff(month,0,InviteDate),0) AS MonthYear,
SignupDate
FROM
(
SELECT OpenId AS OpenIdSender,
ExtraInfo1 AS EmailAddressRetriever,
Timestamp AS InviteDate,
EventType AS InviteType
FROM PlatformAnalytics_PullPush_Platform_Event
WHERE EventType IN ('AppInviteSent','PlatformInviteSent','ProjectInviteSent','ReferralInviteSent')
AND NOT(CompanyId LIKE '%Mendix%') AND OpenId != ''
) a
LEFT JOIN
(
SELECT OpenId,
CompanyId,
email,
OldSignupDate AS SignupDate
FROM PlatformAnalytics_PullPush_Platform_User_Current
) b
ON a.EmailAddressRetriever = b.email
/*
LEFT JOIN
(
SELECT CompanyId,
CASE
WHEN SUM(CASE WHEN IsPartner = 1 THEN 1 ELSE 0 END) > 0 THEN 'Partner'
WHEN SUM(CASE WHEN IsCustomer = 1 THEN 1 ELSE 0 END) > 0 THEN 'Customer'
WHEN SUM(CASE WHEN IsUniversity = 1 THEN 1 ELSE 0 END) > 0 THEN 'University'
ELSE 'Other'
END AS CompanyType
FROM PlatformAnalytics_PullPush_Platform_Company_Current
GROUP BY CompanyId
) c
ON b.CompanyId = c.CompanyId
*/
) a
WHERE MonthYear < dateadd(month,datediff(month,0,GETDATE()),0)