SQL新手求助:Campaign表触达渠道评估及双渠道客户统计查询
SQL Queries for Campaign Channel Analysis
Hey there! As a SQL newbie, I’ll walk you through straightforward, easy-to-understand queries to meet your two requirements using your Campaign table.
1. Evaluate Customer Reach Channels
This query breaks down how customers are being reached across each channel, showing the count of unique customers per channel type:
SELECT Channel, COUNT(DISTINCT "Customer ID") AS unique_customer_count FROM Campaign GROUP BY Channel ORDER BY unique_customer_count DESC;
Quick breakdown:
COUNT(DISTINCT "Customer ID")ensures we count each customer only once per channel, even if they joined multiple campaigns through the same channel.GROUP BY Channelgroups results by each of your three channel options (Direct Email, Email, Both).ORDER BYsorts results from the most to least used channel, so you can spot trends at a glance.
2. Count Customers Reached via Both Channels
To get the number of unique customers who were reached through the "Both" channel:
SELECT COUNT(DISTINCT "Customer ID") AS both_channel_customer_count FROM Campaign WHERE Channel = 'Both';
Quick breakdown:
- The
WHEREclause filters the table to only include records where the channel is "Both". COUNT(DISTINCT "Customer ID")prevents duplicate counts of the same customer, even if they have multiple campaigns tagged with "Both".
内容的提问来源于stack exchange,提问作者Hitesh Shetty
相关产品推荐
相关产品推荐

