SQL Programming Resources
Find top SQL resources from global universities, cool projects, and learning materials for data analytics. Admin: @coderfun Useful links: heylink.me/DataAnalytics Promotions: @love_data
显示更多📈 Telegram 频道 SQL Programming Resources 的分析概览
频道 SQL Programming Resources (@sqlanalyst) 英语 语言赛道中的 是活跃参与者。目前社区聚集了 75 988 名订阅者,在 技术与应用 类别中位列第 1 692,并在 印度 地区排名第 4 136 位。
📊 受众指标与增长动态
自 невідомо 创建以来,项目保持高速增长,吸引了 75 988 名订阅者。
根据 28 六月, 2026 的最新数据,频道保持稳定运转。过去 30 天订阅人数变化为 373,过去 24 小时变化为 -10,整体触达仍然可观。
- 认证状态: 未认证
- 互动率 (ER): 平均受众互动率为 2.35%。内容发布后 24 小时内通常能获得 1.03% 的反应,占订阅者总量。
- 帖子覆盖: 每篇帖子平均可获得 1 783 次浏览,首日通常累积 786 次浏览。
- 互动与反馈: 受众积极参与,单帖平均反应数为 3。
- 主题关注点: 内容集中在 row, sql, customer_id, logic, desc 等核心主题上。
📝 描述与内容策略
作者将该频道定位为表达主观观点的平台:
“Find top SQL resources from global universities, cool projects, and learning materials for data analytics.
Admin: @coderfun
Useful links: heylink.me/DataAnalytics
Promotions: @love_data”
凭借高频更新(最新数据采集于 29 六月, 2026),频道始终保持新鲜度与高覆盖。分析显示受众积极互动,使其成为 技术与应用 类别中的关键影响点。
SELECT c.customer_id
FROM customers c
LEFT JOIN orders o
ON c.customer_id = o.customer_id
GROUP BY c.customer_id
HAVING MAX(order_date) < CURRENT_DATE - INTERVAL '90 days'
OR MAX(order_date) IS NULL;
📌 Question 52: Calculate Average Revenue Per User ARPU
Tables: users (user_id), orders (user_id, amount)
SELECT
ROUND(
SUM(amount) * 1.0 /
COUNT(DISTINCT u.user_id),
2
) AS arpu
FROM users u
LEFT JOIN orders o
ON u.user_id = o.user_id;
📌 Question 53: Find the Fastest Selling Product
Table: inventory (product_id, launch_date)
Table: sales (product_id, sale_date)
Requirement: Find the product with the fewest days from launch to first sale.
WITH first_sale AS (
SELECT
product_id,
MIN(sale_date) AS first_sale_date
FROM sales
GROUP BY product_id
)
SELECT
i.product_id,
(first_sale_date - launch_date) AS days_to_sell
FROM inventory i
JOIN first_sale f
ON i.product_id = f.product_id
ORDER BY days_to_sell
LIMIT 1;
📌 Question 54: Find Customers Who Purchased in Every Quarter
Table: orders (customer_id, order_date)
WITH customer_quarters AS (
SELECT
customer_id,
COUNT(
DISTINCT DATE_TRUNC('quarter', order_date)
) AS quarter_count
FROM orders
GROUP BY customer_id
),
total_quarters AS (
SELECT COUNT(
DISTINCT DATE_TRUNC('quarter', order_date)
) AS total_quarters
FROM orders
)
SELECT customer_id
FROM customer_quarters
CROSS JOIN total_quarters
WHERE quarter_count = total_quarters;
📌 Question 55: Find Revenue Contribution of Top 10 Customers
Table: orders (customer_id, amount)
WITH customer_revenue AS (
SELECT
customer_id,
SUM(amount) AS revenue
FROM orders
GROUP BY customer_id
)
SELECT
SUM(revenue) AS top10_revenue,
ROUND(
100.0 * SUM(revenue) /
(
SELECT SUM(amount)
FROM orders
),
2
) AS contribution_pct
FROM (
SELECT revenue
FROM customer_revenue
ORDER BY revenue DESC
LIMIT 10
) t;
📌 Question 56: Find Products Never Returned
Tables:
products (product_id)
sales (order_id, product_id)
returns (order_id)
SELECT DISTINCT
p.product_id
FROM products p
LEFT JOIN sales s
ON p.product_id = s.product_id
LEFT JOIN returns r
ON s.order_id = r.order_id
WHERE r.order_id IS NULL;
📌 Question 57: Calculate Daily Revenue Growth
Table: sales (sale_date, amount)
WITH daily_sales AS (
SELECT
sale_date,
SUM(amount) AS revenue
FROM sales
GROUP BY sale_date
)
SELECT
sale_date,
revenue,
ROUND(
100.0 *
(
revenue -
LAG(revenue) OVER(
ORDER BY sale_date
)
/
LAG(revenue) OVER(
ORDER BY sale_date
),
2
) AS growth_pct
FROM daily_sales;
📌 Question 58: Find the Most Loyal Customers
Table: orders (customer_id, order_date)
Requirement: Customers who placed orders in the highest number of distinct months.
SELECT
customer_id,
COUNT(
DISTINCT DATE_TRUNC('month', order_date)
) AS active_months
FROM orders
GROUP BY customer_id
ORDER BY active_months DESC
LIMIT 10;
📌 Question 59: Find Products With Zero Sales
Tables:
products (product_id)
sales (product_id)
SELECT
p.product_id
FROM products p
LEFT JOIN sales s
ON p.product_id = s.product_id
WHERE s.product_id IS NULL;
📌 Question 60: Calculate Average Orders Per Customer
Table: orders (customer_id)
SELECT
ROUND(
COUNT(*) * 1.0 /
COUNT(DISTINCT customer_id),
2
) AS avg_orders_per_customer
FROM orders;
❤️ Double Tap For MoreSELECT
EXTRACT(HOUR FROM order_timestamp) AS order_hour,
COUNT(*) AS total_orders
FROM orders
GROUP BY order_hour
ORDER BY total_orders DESC
LIMIT 1;
📌 Question 40: Rank Salespersons by Quarterly Revenue
Table: sales salesperson_id, amount, sale_date
WITH quarterly_sales AS (
SELECT
salesperson_id,
DATE_TRUNC('quarter', sale_date) AS quarter,
SUM(amount) AS revenue
FROM sales
GROUP BY 1,2
)
SELECT *,
DENSE_RANK() OVER (
PARTITION BY quarter
ORDER BY revenue DESC
) AS sales_rank
FROM quarterly_sales;
Double Tap ❤️ For MoreSELECT
EXTRACT(HOUR FROM order_timestamp) AS order_hour,
COUNT(*) AS total_orders
FROM orders
GROUP BY order_hour
ORDER BY total_orders DESC
LIMIT 1;
📌 Question 40: Rank Salespersons by Quarterly Revenue
Table: sales salesperson_id, amount, sale_date
WITH quarterly_sales AS (
SELECT
salesperson_id,
DATE_TRUNC('quarter', sale_date) AS quarter,
SUM(amount) AS revenue
FROM sales
GROUP BY 1,2
)
SELECT *,
DENSE_RANK() OVER (
PARTITION BY quarter
ORDER BY revenue DESC
) AS sales_rank
FROM quarterly_sales;
Double Tap ❤️ For More
-----
1.38 ₽ · /balance_helpWITH monthly_spend AS (
SELECT
customer_id,
DATE_TRUNC('month', order_date) AS month,
SUM(amount) AS total_spend
FROM orders
GROUP BY customer_id, DATE_TRUNC('month', order_date)
)
SELECT
customer_id,
month,
total_spend
FROM (
SELECT *,
LAG(total_spend) OVER (
PARTITION BY customer_id
ORDER BY month
) AS prev_spend
FROM monthly_spend
) t
WHERE total_spend > prev_spend;
📌 Question 32: Find Products Purchased Together Most Often
Table: order_items order_id, product_id
SELECT
a.product_id AS product_1,
b.product_id AS product_2,
COUNT(*) AS frequency
FROM order_items a
JOIN order_items b
ON a.order_id = b.order_id
AND a.product_id < b.product_id
GROUP BY 1,2
ORDER BY frequency DESC
LIMIT 10;
📌 Question 33: Find Users Active for 7 Consecutive Days
Table: user_activity user_id, activity_date
WITH activity AS (
SELECT
user_id,
activity_date,
activity_date -
ROW_NUMBER() OVER (
PARTITION BY user_id
ORDER BY activity_date
) * INTERVAL '1 day' AS grp
FROM user_activity
)
SELECT
user_id
FROM activity
GROUP BY user_id, grp
HAVING COUNT(*) >= 7;
📌 Question 34: Calculate Repeat Purchase Rate
Table: orders customer_id, order_id
SELECT
ROUND(
100.0 *
COUNT(CASE WHEN order_count > 1 THEN 1 END) /
COUNT(*),
2
) AS repeat_purchase_rate
FROM (
SELECT
customer_id,
COUNT(*) AS order_count
FROM orders
GROUP BY customer_id
) t;
📌 Question 35: Find the Longest Gap Between Two Orders
Table: orders customer_id, order_date
WITH gaps AS (
SELECT
customer_id,
order_date,
order_date -
LAG(order_date) OVER (
PARTITION BY customer_id
ORDER BY order_date
) AS gap_days
FROM orders
)
SELECT
customer_id,
MAX(gap_days) AS longest_gap
FROM gaps
GROUP BY customer_id;
📌 Question 36: Calculate Revenue Lost Due to Churn
Tables: customers customer_id, status, orders customer_id, amount
SELECT
SUM(amount) AS churned_revenue
FROM customers c
JOIN orders o
ON c.customer_id = o.customer_id
WHERE c.status = 'Churned';
📌 Question 37: Find the Fastest Growing Product
Table: sales product_id, amount, sale_date
WITH monthly_sales AS (
SELECT
product_id,
DATE_TRUNC('month', sale_date) AS month,
SUM(amount) AS revenue
FROM sales
GROUP BY 1,2
)
SELECT *
FROM (
SELECT *,
revenue -
LAG(revenue) OVER (
PARTITION BY product_id
ORDER BY month
) AS growth
FROM monthly_sales
) t
ORDER BY growth DESC
LIMIT 1;
📌 Question 38: Find Customers Who Purchased Every Product Category
Tables: products product_id, category, orders customer_id, product_id
SELECT
customer_id
FROM orders o
JOIN products p
ON o.product_id = p.product_id
GROUP BY customer_id
HAVING COUNT(DISTINCT category) = (
SELECT COUNT(DISTINCT category)
FROM products
);
📌 Question 39: Find Peak Ordering Hour
Table: orders order_id, order_timestampSELECT
customer_id,
MIN(order_date) AS first_purchase_date
FROM orders
GROUP BY customer_id;
📌 Question 22: Calculate Customer Lifetime Value (CLV)
Table: orders customer_id, amount
Requirement: Total revenue generated by each customer.
SELECT
customer_id,
SUM(amount) AS lifetime_value
FROM orders
GROUP BY customer_id
ORDER BY lifetime_value DESC;
📌 Question 23: Find the Top 5 Products Contributing 80% of Revenue
Table: sales product_id, amount
WITH product_revenue AS (
SELECT
product_id,
SUM(amount) AS revenue
FROM sales
GROUP BY product_id
),
revenue_rank AS (
SELECT
product_id,
revenue,
SUM(revenue) OVER (ORDER BY revenue DESC) AS running_revenue,
SUM(revenue) OVER () AS total_revenue
FROM product_revenue
)
SELECT
product_id,
revenue,
ROUND(100.0 * running_revenue / total_revenue, 2) AS cumulative_pct
FROM revenue_rank
WHERE running_revenue <= total_revenue * 0.80;
📌 Question 24: Find Customers Who Purchased More Than 3 Different Products
Table: orders customer_id, product_id
SELECT
customer_id
FROM orders
GROUP BY customer_id
HAVING COUNT(DISTINCT product_id) > 3;
📌 Question 25: Find the Highest Revenue Order for Each Customer
Table: orders order_id, customer_id, amount
WITH ranked_orders AS (
SELECT *,
ROW_NUMBER() OVER (
PARTITION BY customer_id
ORDER BY amount DESC
) AS rn
FROM orders
)
SELECT
customer_id,
order_id,
amount
FROM ranked_orders
WHERE rn = 1;
📌 Question 26: Calculate Average Time Between Orders
Table: orders customer_id, order_date
WITH order_gap AS (
SELECT
customer_id,
order_date,
LAG(order_date) OVER (
PARTITION BY customer_id
ORDER BY order_date
) AS previous_order
FROM orders
)
SELECT
customer_id,
AVG(order_date - previous_order) AS avg_days_between_orders
FROM order_gap
WHERE previous_order IS NOT NULL
GROUP BY customer_id;
📌 Question 27: Find Users Who Abandoned Their Cart
Tables: cart user_id, product_id, orders user_id
Requirement: Users who added items to their cart but never completed a purchase.
SELECT DISTINCT
c.user_id
FROM cart c
LEFT JOIN orders o
ON c.user_id = o.user_id
WHERE o.user_id IS NULL;
📌 Question 28: Find Revenue Generated by New vs Returning Customers
Tables: users user_id, signup_date, orders user_id, amount, order_date
SELECT
CASE
WHEN DATE_TRUNC('month', signup_date) =
DATE_TRUNC('month', order_date)
THEN 'New'
ELSE 'Returning'
END AS customer_type,
SUM(amount) AS revenue
FROM users u
JOIN orders o
ON u.user_id = o.user_id
GROUP BY customer_type;
📌 Question 29: Find the Most Frequently Purchased Product Pair
Table: order_items order_id, product_id
SELECT
a.product_id AS product_1,
b.product_id AS product_2,
COUNT(*) AS pair_count
FROM order_items a
JOIN order_items b
ON a.order_id = b.order_id
AND a.product_id < b.product_id
GROUP BY
a.product_id,
b.product_id
ORDER BY pair_count DESC
LIMIT 1;
📌 Question 30: Calculate Revenue Contribution by Region
Tables: customers customer_id, region, orders customer_id, amount
SELECT
c.region,
SUM(o.amount) AS revenue,
ROUND(
100.0 * SUM(o.amount) /
SUM(SUM(o.amount)) OVER (),
2
) AS revenue_share
FROM customers c
JOIN orders o
ON c.customer_id = o.customer_id
GROUP BY c.region
ORDER BY revenue DESC;
Double Tap ❤️ For More
现已上线!2025 年 Telegram 研究 — 年度关键洞察 
