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
Show more📈 Analytical overview of Telegram channel Data Science & Machine Learning
Channel Data Science & Machine Learning (@datasciencefun) in the English language segment is an active participant. Currently, the community unites 77 452 subscribers, ranking 2 023 in the Education category and 3 814 in the India region.
📊 Audience metrics and dynamics
Since its creation on невідомо, the project has demonstrated rapid growth, gathering an audience of 77 452 subscribers.
According to the latest data from 04 December, 2026, the channel demonstrates stable activity. Although there has been a change in the number of participants by -283 over the last 30 days and by -16 over the last 24 hours, overall reach remains high.
- Verification status: Not verified
- Engagement rate (ER): The average audience engagement rate is 2.11%. Within the first 24 hours after publication, content typically collects 0.84% reactions from the total number of subscribers.
- Post reach: On average, each post receives 1 633 views. Within the first day, a publication typically gains 649 views.
- Reactions and interaction: The audience actively supports content: the average number of reactions per post is 2.
- Thematic interests: Content is focused on key topics such as learning, accuracy, distribution, panda, dataset.
📝 Description and content policy
The author describes the resource as a platform for expressing subjective opinions:
“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”
Thanks to the high frequency of updates (latest data received on 05 December, 2026), the channel maintains relevance and a high level of publication reach. Analytics show that the audience actively interacts with content, making it an important point of influence in the Education category.
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:
