Data Science & Machine Learning
Join this channel to learn data science, artificial intelligence and machine learning with funny quizzes, interesting projects and amazing resources for free For collaborations: @love_data
显示更多📈 Telegram 频道 Data Science & Machine Learning 的分析概览
频道 Data Science & Machine Learning (@datasciencefun) 英语 语言赛道中的 是活跃参与者。目前社区聚集了 77 452 名订阅者,在 教育 类别中位列第 2 023,并在 印度 地区排名第 3 814 位。
📊 受众指标与增长动态
自 невідомо 创建以来,项目保持高速增长,吸引了 77 452 名订阅者。
根据 04 十二月, 2026 的最新数据,频道保持稳定运转。过去 30 天订阅人数变化为 -283,过去 24 小时变化为 -16,整体触达仍然可观。
- 认证状态: 未认证
- 互动率 (ER): 平均受众互动率为 2.11%。内容发布后 24 小时内通常能获得 0.84% 的反应,占订阅者总量。
- 帖子覆盖: 每篇帖子平均可获得 1 633 次浏览,首日通常累积 649 次浏览。
- 互动与反馈: 受众积极参与,单帖平均反应数为 2。
- 主题关注点: 内容集中在 learning, accuracy, distribution, panda, dataset 等核心主题上。
📝 描述与内容策略
作者将该频道定位为表达主观观点的平台:
“Join this channel to learn data science, artificial intelligence and machine learning with funny quizzes, interesting projects and amazing resources for free
For collaborations: @love_data”
凭借高频更新(最新数据采集于 05 十二月, 2026),频道始终保持新鲜度与高覆盖。分析显示受众积极互动,使其成为 教育 类别中的关键影响点。
Find the total sales for each customer.Ask yourself: 👉 What do I need to display? Answer: Customer Total Sales 📌 Step 2: Identify the Table Find which table contains the required information. Suppose you have: sales customer_id product quantity price You need the sales table. 📌 Step 3: Identify the Required Columns For:
Find total sales for each customer.You need: customer_id quantity price Because: Sales = quantity × price 📌 Step 4: Decide Whether You Need Filtering Ask:
Do I need only certain rows?For example:
Find total sales for customers who purchased in 2026.Now you need a WHERE condition. WHERE order_date >= '2026-01-01' 📌 Step 5: Decide Whether You Need GROUP BY Look for words such as: Each customer, Each department, Per product, By region, By month These usually indicate GROUP BY. For example:
Find total sales for each customer.GROUP BY customer_id 📌 Step 6: Identify the Required Aggregate Function Look for words like: Total → SUM() Average → AVG() Count → COUNT() Maximum → MAX() Minimum → MIN() For total sales: SUM(quantity _ price) 📌 Step 7: Build the Query Step by Step Instead of writing everything at once: 1. SELECT customer_id FROM sales; 2. Add the calculation: SELECT customer_id, SUM(quantity _ price) AS total_sales FROM sales; 3. Add grouping: SELECT customer_id, SUM(quantity * price) AS total_sales FROM sales GROUP BY customer_id; Now the query is complete. 📌 Step 8: Check Whether You Need HAVING Suppose the question changes to:
Find customers whose total sales are greater than ₹50,000.You cannot use WHERE on SUM(). Use HAVING: SELECT customer_id, SUM(quantity * price) AS total_sales FROM sales GROUP BY customer_id HAVING SUM(quantity * price) > 50000; 📌 Step 9: Check Whether You Need a JOIN Suppose the question says:
Find the names of customers and their total sales.You have: customers: customer_id, customer_name sales: customer_id, quantity, price Now you need a JOIN. SELECT c.customer_name, SUM(s.quantity * s.price) AS total_sales FROM customers c JOIN sales s ON c.customer_id = s.customer_id GROUP BY c.customer_name; 📌 Step 10: Validate Your Answer Before considering the problem solved, check: ✓ Did I use the correct table? ✓ Did I select the correct columns? ✓ Is my JOIN correct? ✓ Did I handle NULL values? ✓ Did I accidentally create duplicates? ✓ Did I use WHERE or HAVING correctly? ✓ Does the output actually answer the question? 🧠 Use This SQL Problem-Solving Framework Whenever you get a SQL question, think: 1. What is being asked? 2. Which table(s) do I need? 3. Which columns do I need? 4. Do I need filtering? 5. Do I need a JOIN? 6. Do I need aggregation? 7. Do I need GROUP BY? 8. Do I need HAVING? 9. Do I need a window function? 10. Validate the result 🔥 Double Tap ❤️ For More SQL Tips
SELECT
department,
AVG(salary) AS average_salary
FROM employees
GROUP BY department;
Window Function:
SELECT
employee_name,
department,
salary,
AVG(salary) OVER (
PARTITION BY department
) AS average_salary
FROM employees;
Remember: GROUP BY summarizes rows, while Window Functions calculate values across rows without collapsing them into one row per group.
🔹 9. Window Functions vs Regular Aggregate Functions
Regular aggregate function:
SELECT AVG(salary)
FROM employees;
Returns one average value.
Window aggregate function:
SELECT
employee_name,
salary,
AVG(salary) OVER () AS average_salary
FROM employees;
Returns every employee along with the average salary.
This is why Window Functions are so useful in analytical queries.
🔹 10. Real-World Data Science Use Cases
Window Functions are frequently used for:
• Calculating running sales totals.
• Comparing employee salaries with department averages.
• Calculating cumulative revenue.
• Finding monthly sales trends.
• Calculating moving averages.
• Comparing current and previous transactions.
• Analyzing customer purchase behavior.
• Preparing analytical datasets for dashboards.
🔹 11. Common Mistakes to Avoid
• Forgetting the OVER() clause.
• Confusing PARTITION BY with GROUP BY.
• Assuming PARTITION BY reduces the number of rows.
• Using ORDER BY without understanding its effect on the window calculation.
• Forgetting to define a proper window frame for running totals.
• Assuming the ORDER BY inside OVER() sorts the final query output.
Important: The ORDER BY inside OVER() controls the window calculation. To sort the final result, use an outer ORDER BY clause.
🔹 12. SQL Interview Questions
Q1. What is a Window Function in SQL?
A function that performs calculations across a set of related rows without collapsing them into a single row.
Q2. What is the purpose of OVER()?
It defines the window of rows used by the Window Function.
Q3. What is PARTITION BY?
It divides rows into groups for window calculations without reducing the number of rows.
Q4. What is the difference between GROUP BY and PARTITION BY?
GROUP BY combines rows into summarized groups, while PARTITION BY creates logical groups for window calculations and retains individual rows.
Q5. What is a Running Total?
A cumulative sum calculated progressively across ordered rows.
🎯 Practice Questions
Try writing SQL queries for these problems:
• Calculate the average salary across all employees using a Window Function.
• Calculate department-wise average salary while displaying every employee.
• Calculate total sales across all transactions.
• Calculate a running total of sales ordered by transaction date.
• Find the highest and lowest salary while displaying every employee.
🎯 Key Takeaways
• Window Functions perform calculations across related rows.
• OVER() defines the window.
• PARTITION BY divides rows into groups.
• ORDER BY defines the calculation order.
• Aggregate functions such as SUM, AVG, COUNT, MIN, and MAX can be used as Window Functions.
• Window Functions preserve individual rows.
• Running totals are a common use case.
• Window Functions are essential for advanced SQL analytics.
Double Tap ❤️ For More
-----
2.49 ₽ · /balance_helpSUM(amount) OVER (
ORDER BY sale_date
ROWS BETWEEN UNBOUNDED PRECEDING
AND CURRENT ROW
)
Let's understand the terms:
• ROWS specifies that the frame is based on physical rows.
• UNBOUNDED PRECEDING starts from the first row in the ordered partition.
• CURRENT ROW ends at the current row.
Other useful frame options:
• 1 PRECEDING → One row before the current row.
• 1 FOLLOWING → One row after the current row.
• UNBOUNDED FOLLOWING → Last row in the partition.
🔹 8. Window Functions vs GROUP BY
This is one of the most important SQL interview questions.SELECT
sale_id,
sale_date,
amount,
SUM(amount) OVER (
ORDER BY sale_date
ROWS BETWEEN UNBOUNDED PRECEDING
AND CURRENT ROW
) AS running_total
FROM sales;
Result:PARTITION BY divides records into separate groups for calculations.
Example: Calculate average salary department-wise.
SELECT
employee_name,
department,
salary,
AVG(salary) OVER (
PARTITION BY department
) AS department_average
FROM employees;
Here:
• IT employees are calculated together.
• HR employees are calculated together.
• Finance employees are calculated together.
However, all employee records remain visible.
Important: PARTITION BY does not physically group or sort the original table. It defines the groups used by the window calculation.
🔹 5. Aggregate Window Functions
You can use aggregate functions with Window Functions.
The most commonly used are:
1. SUM() OVER()
Calculate total salary across all employees.
SELECT
employee_name,
salary,
SUM(salary) OVER () AS total_salary
FROM employees;
2. AVG() OVER()
Calculate average salary.
SELECT
employee_name,
salary,
AVG(salary) OVER () AS average_salary
FROM employees;
3. COUNT() OVER()
Count the total number of employees.
SELECT
employee_name,
COUNT(*) OVER () AS total_employees
FROM employees;
4. MAX() OVER()
Find the highest salary.
SELECT
employee_name,
salary,
MAX(salary) OVER () AS highest_salary
FROM employees;
5. MIN() OVER()
Find the lowest salary.
SELECT
employee_name,
salary,
MIN(salary) OVER () AS lowest_salary
FROM employees;
🔹 6. Window Functions with ORDER BY
You can use ORDER BY inside OVER() to perform calculations based on row order.
Example: Calculate running total of sales.
Suppose we have a sales table:
