SELECT qsaccel.profile_agg.adwh_dim_merge_policies.merge_policy_name,
sum(qsaccel.profile_agg.adwh_fact_profile.count_of_profiles) CNT
FROM qsaccel.profile_agg.adwh_fact_profile
LEFT OUTER JOIN qsaccel.profile_agg.adwh_dim_merge_policies ON qsaccel.profile_agg.adwh_dim_merge_policies.merge_policy_id=adwh_fact_profile.merge_policy_id
WHERE qsaccel.profile_agg.adwh_fact_profile.date_key='2024-01-10'
AND qsaccel.profile_agg.adwh_fact_profile.merge_policy_id = 2027892989
GROUP BY qsaccel.profile_agg.adwh_dim_merge_policies.merge_policy_name;
SELECT qsaccel.profile_agg.adwh_dim_merge_policies.merge_policy_name,
sum(qsaccel.profile_agg.adwh_fact_profile.count_of_Single_Identity_profiles) CNT
FROM qsaccel.profile_agg.adwh_fact_profile
LEFT OUTER JOIN qsaccel.profile_agg.adwh_dim_merge_policies ON qsaccel.profile_agg.adwh_dim_merge_policies.merge_policy_id=adwh_fact_profile.merge_policy_id
WHERE qsaccel.profile_agg.adwh_fact_profile.date_key='2024-01-10'
AND qsaccel.profile_agg.adwh_fact_profile.merge_policy_id = 2027892989
GROUP BY qsaccel.profile_agg.adwh_dim_merge_policies.merge_policy_name;
SELECT qsaccel.profile_agg.adwh_dim_namespaces.namespace_description,
sum(qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.count_of_profiles) count_of_profiles
FROM qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines
LEFT OUTER JOIN qsaccel.profile_agg.adwh_dim_namespaces ON qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.namespace_id = qsaccel.profile_agg.adwh_dim_namespaces.namespace_id
AND qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.merge_policy_id = qsaccel.profile_agg.adwh_dim_namespaces.merge_policy_id
WHERE qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.merge_policy_id = 2027892989
AND qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.date_key = '2024-01-10'
GROUP BY qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.date_key,
qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.merge_policy_id,
qsaccel.profile_agg.adwh_dim_namespaces.namespace_description
ORDER BY count_of_profiles DESC;
SELECT qsaccel.profile_agg.adwh_dim_namespaces.namespace_description,
sum(qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.count_of_Single_Identity_profiles) count_of_Single_Identity_profiles
FROM qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines
LEFT OUTER JOIN qsaccel.profile_agg.adwh_dim_namespaces ON qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.namespace_id = qsaccel.profile_agg.adwh_dim_namespaces.namespace_id
AND qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.merge_policy_id = qsaccel.profile_agg.adwh_dim_namespaces.merge_policy_id
WHERE qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.merge_policy_id = 2027892989
AND qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.date_key = '2024-01-10'
GROUP BY qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.date_key,
qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.merge_policy_id,
qsaccel.profile_agg.adwh_dim_namespaces.namespace_description;
SELECT
sum(
qsaccel.profile_agg.adwh_fact_profile_by_segment_trendlines.count_of_profiles
) count_of_profiles
FROM
qsaccel.profile_agg.adwh_fact_profile_by_segment_trendlines
LEFT OUTER JOIN qsaccel.profile_agg.adwh_dim_segments ON qsaccel.profile_agg.adwh_fact_profile_by_segment_trendlines.segment_id = qsaccel.profile_agg.adwh_dim_segments.segment_id
WHERE
qsaccel.profile_agg.adwh_fact_profile_by_segment_trendlines.segment_id = -1323307941
AND qsaccel.profile_agg.adwh_fact_profile_by_segment_trendlines.merge_policy_id = 1914917902
AND qsaccel.profile_agg.adwh_fact_profile_by_segment_trendlines.date_key = '2024-01-12';
SELECT date_key,
Profiles_added
FROM
(SELECT rn_num,
date_key,
(count_of_profiles-lag(count_of_profiles, 1, 0) over(
ORDER BY date_key))Profiles_added
FROM
(SELECT date_key,
sum(x.count_of_profiles)count_of_profiles,
row_number() OVER (
ORDER BY date_key) rn_num
FROM qsaccel.profile_agg.adwh_fact_profile_by_segment_trendlines x
INNER JOIN
(SELECT MAX(process_date) last_process_date,
merge_policy_id
FROM qsaccel.profile_agg.adwh_lkup_process_delta_log
WHERE process_name = 'FACT_TABLES_PROCESSING'
AND process_status = 'SUCCESSFUL'
GROUP BY merge_policy_id) y ON x.merge_policy_id = y.merge_policy_id
WHERE segment_id = 1333234510
AND x.date_key >= dateadd(DAY, -30 -1, y.last_process_date)
GROUP BY x.date_key) a)b
WHERE rn_num > 1;
SELECT qsaccel.profile_agg.adwh_dim_destination.destination_name,
qsaccel.profile_agg.adwh_dim_destination.destination_id,
qsaccel.profile_agg.adwh_dim_destination.destination,
count(DISTINCT qsaccel.profile_agg.adwh_dim_br_segment_destinations.segment_id) segment_count
FROM qsaccel.profile_agg.adwh_dim_destination
JOIN qsaccel.profile_agg.adwh_dim_br_segment_destinations ON qsaccel.profile_agg.adwh_dim_destination.destination_id = qsaccel.profile_agg.adwh_dim_br_segment_destinations.destination_id
WHERE qsaccel.profile_agg.adwh_dim_destination.destination_name IS NOT NULL
GROUP BY qsaccel.profile_agg.adwh_dim_destination.destination_name,
qsaccel.profile_agg.adwh_dim_destination.destination,
qsaccel.profile_agg.adwh_dim_destination.destination_id
ORDER BY segment_count DESC
LIMIT 20;
SELECT
segment_name,
segment,
destination_name,
a.create_time create_time
FROM
qsaccel.profile_agg.adwh_dim_br_segment_destinations a
INNER JOIN qsaccel.profile_agg.adwh_dim_segments b ON a.segment_id = b.segment_id
INNER JOIN qsaccel.profile_agg.adwh_dim_destination c ON a.destination_id = c.destination_id
ORDER BY
create_time DESC,
segment
LIMIT
20;
SELECT qsaccel.profile_agg.adwh_dim_namespaces.namespace_description,
sum(qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines.count_of_profiles) count_of_profiles
FROM qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines
LEFT OUTER JOIN qsaccel.profile_agg.adwh_dim_namespaces ON qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines.namespace_id = qsaccel.profile_agg.adwh_dim_namespaces.namespace_id
AND qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines.merge_policy_id = qsaccel.profile_agg.adwh_dim_namespaces.merge_policy_id
WHERE qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines.segment_id = 1333234510
AND qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines.merge_policy_id = 1709997014
AND qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines.date_key = '2024-01-10'
GROUP BY qsaccel.profile_agg.adwh_dim_namespaces.namespace_description
ORDER BY count_of_profiles DESC;
SELECT Sum(overlap_col1) overlap_col1,
Sum(overlap_col2) overlap_col2,
coalesce(Sum(overlap_count), 0) overlap_count
FROM
(SELECT 0 overlap_col1,
0 overlap_col2,
Sum(count_of_profiles) overlap_count
FROM qsaccel.profile_agg.adwh_fact_profile_overlap_of_namespace
WHERE qsaccel.profile_agg.adwh_fact_profile_overlap_of_namespace.merge_policy_id = 2027892989
AND qsaccel.profile_agg.adwh_fact_profile_overlap_of_namespace.date_key = '2024-01-10'
AND qsaccel.profile_agg.adwh_fact_profile_overlap_of_namespace.overlap_id IN
(SELECT a.overlap_id
FROM
(SELECT qsaccel.profile_agg.adwh_dim_overlap_namespaces.overlap_id overlap_id,
count(*) cnt_num
FROM qsaccel.profile_agg.adwh_dim_overlap_namespaces
WHERE qsaccel.profile_agg.adwh_dim_overlap_namespaces.merge_policy_id = 2027892989
AND qsaccel.profile_agg.adwh_dim_overlap_namespaces.overlap_namespaces in ('avid',
'crmid')
GROUP BY qsaccel.profile_agg.adwh_dim_overlap_namespaces.overlap_id)a
WHERE a.cnt_num>1 )
UNION ALL SELECT count_of_profiles overlap_col1,
0 overlap_col2,
0 overlap_count
FROM qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines
JOIN qsaccel.profile_agg.adwh_dim_namespaces ON qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.namespace_id = qsaccel.profile_agg.adwh_dim_namespaces.namespace_id
AND qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.merge_policy_id = qsaccel.profile_agg.adwh_dim_namespaces.merge_policy_id
WHERE qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.merge_policy_id = 2027892989
AND qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.date_key = '2024-01-10'
AND qsaccel.profile_agg.adwh_dim_namespaces.namespace_description = 'avid'
UNION ALL SELECT 0 overlap_col1,
count_of_profiles overlap_col2,
0 Overlap_count
FROM qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines
JOIN qsaccel.profile_agg.adwh_dim_namespaces ON qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.namespace_id = qsaccel.profile_agg.adwh_dim_namespaces.namespace_id
AND qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.merge_policy_id = qsaccel.profile_agg.adwh_dim_namespaces.merge_policy_id
WHERE qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.merge_policy_id = 2027892989
AND qsaccel.profile_agg.adwh_fact_profile_by_namespace_trendlines.date_key = '2024-01-10'
AND qsaccel.profile_agg.adwh_dim_namespaces.namespace_description = 'crmid' )a;
SELECT Sum(overlap_col1) overlap_col1,
Sum(overlap_col2) overlap_col2,
Sum(overlap_count) Overlap_count
FROM
(SELECT 0 overlap_col1,
0 overlap_col2,
Sum(count_of_profiles) Overlap_count
FROM qsaccel.profile_agg.adwh_fact_profile_overlap_of_namespace_by_segment
WHERE qsaccel.profile_agg.adwh_fact_profile_overlap_of_namespace_by_segment.segment_id = 1333234510
AND qsaccel.profile_agg.adwh_fact_profile_overlap_of_namespace_by_segment.merge_policy_id = 1709997014
AND qsaccel.profile_agg.adwh_fact_profile_overlap_of_namespace_by_segment.date_key = '2024-01-10'
AND qsaccel.profile_agg.adwh_fact_profile_overlap_of_namespace_by_segment.overlap_id IN
(SELECT a.overlap_id
FROM
(SELECT qsaccel.profile_agg.adwh_dim_overlap_namespaces.overlap_id overlap_id,
count(*) cnt_num
FROM qsaccel.profile_agg.adwh_dim_overlap_namespaces
WHERE qsaccel.profile_agg.adwh_dim_overlap_namespaces.merge_policy_id = 1709997014
AND qsaccel.profile_agg.adwh_dim_overlap_namespaces.overlap_namespaces in ('crmid',
'email')
GROUP BY qsaccel.profile_agg.adwh_dim_overlap_namespaces.overlap_id)a
WHERE a.cnt_num>1 )
UNION ALL SELECT count_of_profiles overlap_col1,
0 overlap_col2,
0 Overlap_count
FROM qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines
LEFT OUTER JOIN qsaccel.profile_agg.adwh_dim_namespaces ON qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines.namespace_id = qsaccel.profile_agg.adwh_dim_namespaces.namespace_id
AND qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines.merge_policy_id = qsaccel.profile_agg.adwh_dim_namespaces.merge_policy_id
WHERE qsaccel.profile_agg.adwh_dim_namespaces.namespace_description = 'crmid'
AND qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines.segment_id = 1333234510
AND qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines.merge_policy_id = 1709997014
AND qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines.date_key = '2024-01-10'
UNION ALL SELECT 0 overlap_col1,
count_of_profiles overlap_col2,
0 Overlap_count
FROM qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines
LEFT OUTER JOIN qsaccel.profile_agg.adwh_dim_namespaces ON qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines.namespace_id = qsaccel.profile_agg.adwh_dim_namespaces.namespace_id
AND qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines.merge_policy_id = qsaccel.profile_agg.adwh_dim_namespaces.merge_policy_id
WHERE qsaccel.profile_agg.adwh_dim_namespaces.namespace_description = 'email'
AND qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines.segment_id = 1333234510
AND qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines.merge_policy_id = 1709997014
AND qsaccel.profile_agg.adwh_fact_profile_by_segment_and_namespace_trendlines.date_key = '2024-01-10' ) a;