forked from kpaganopoulos/dma
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery2.sql
More file actions
23 lines (22 loc) · 827 Bytes
/
query2.sql
File metadata and controls
23 lines (22 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
CREATE VIEW contacted_and_ordered AS
(
SELECT contacttype, dmefextractordersv01.cust_id
FROM dmefextractcontactsv01
INNER JOIN dmefextractordersv01
ON dmefextractcontactsv01.cust_id = dmefextractordersv01.cust_id
)
SELECT COUNT(contacted_and_ordered.cust_id) AS total_contacted_and_ordered_catalog
FROM contacted_and_ordered
WHERE contacted_and_ordered.contacttype = 'C'
UNION
SELECT COUNT(dmefextractcontactsv01.cust_id) AS total_contacted
FROM dmefextractcontactsv01
WHERE dmefextractcontactsv01.contacttype = 'C'
UNION
SELECT COUNT(contacted_and_ordered.cust_id) AS total_contacted_and_ordered_email
FROM contacted_and_ordered
WHERE contacted_and_ordered.contacttype = 'E'
UNION
SELECT COUNT(dmefextractcontactsv01.cust_id) AS total_contacted
FROM dmefextractcontactsv01
WHERE dmefextractcontactsv01.contacttype = 'E'