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 741 підписників, посідаючи 2 010 місце в категорії Освіта та 3 917 місце у регіоні Індія.
📊 Показники аудиторії та динаміка
З моменту свого створення невідомо, проект продемонстрував стрімке зростання, зібравши аудиторію у 77 741 підписників.
За останніми даними від 25 жовтня, 2026, канал демонструє стабільну активність. Хоча за останні 30 днів спостерігається зміна кількості учасників на 175, а за останні 24 години на 0, загальне охоплення залишається високим.
- Статус верифікації: Не верифікований
- Рівень залученості (ER): Середній показник залученості аудиторії становить 2.75%. Протягом перших 24 годин після публікації контент зазвичай збирає 1.13% реакцій від загальної кількості підписників.
- Охоплення публікацій: В середньому кожен допис отримує 2 139 переглядів. Протягом першої доби публікація в середньому набирає 882 переглядів.
- Реакції та взаємодія: Аудиторія активно підтримує контент: середня кількість реакцій на один пост – 3.
- Тематичні інтереси: Контент зосереджений навколо ключових тем, таких як 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”
Завдяки високій частоті оновлень (останні дані отримано 26 жовтня, 2026), канал підтримує актуальність та високий рівень охоплення публікацій. Аналітика показує, що аудиторія активно взаємодіє з контентом, що робить його важливою точкою впливу в категорії Освіта.
SELECT p.product_name,
SUM(o.quantity * o.price) AS revenue
FROM orders o
INNER JOIN products p
ON o.product_id = p.product_id
GROUP BY p.product_name
ORDER BY revenue DESC;
This combines:
Orders
↓
Products
↓
GROUP BY
↓
Revenue calculation
↓
ORDER BY
↓
Highest revenue first
This type of SQL is directly useful for preparing datasets for Data Science and business analysis.
🔹 Common JOIN Mistakes
Mistake 1 — Missing the JOIN condition
Incorrect:
SELECT *
FROM customers
JOIN orders;
Unless intentionally using a CROSS JOIN, you normally need a relationship condition.
Mistake 2 — Joining on the wrong column
Always identify the actual relationship between the tables.
For example:
customers.customer_id
↕
orders.customer_id
Mistake 3 — Unexpected duplicate rows
Suppose one customer has 10 orders.
After joining:
Customer A
Customer A
Customer A
...
may appear 10 times.
This is not necessarily an error.
The JOIN is representing the one-to-many relationship.
Mistake 4 — Accidentally turning a LEFT JOIN into an INNER JOIN
Consider:
SELECT c.name, o.amount
FROM customers c
LEFT JOIN orders o
ON c.customer_id = o.customer_id
WHERE o.amount > 1000;
The WHERE condition removes rows where o.amount is NULL, so customers without orders disappear.
Understanding how filtering interacts with joins is very important.
🔹 JOIN Cheat Sheet
INNER JOIN
→ Matching rows from both tables
LEFT JOIN
→ All left rows + matching right rows
RIGHT JOIN
→ All right rows + matching left rows
FULL OUTER JOIN
→ All rows from both tables
CROSS JOIN
→ Every possible combination
SELF JOIN
→ A table joined with itself
🔹 Interview Questions
1. What is a JOIN?
A JOIN combines data from multiple tables using a related column or condition.
2. What does INNER JOIN return?
Only rows with matching values in both tables.
3. What does LEFT JOIN return?
All rows from the left table and matching rows from the right table.
4. How do you find customers who have never placed an order?
Use a LEFT JOIN and check for NULL on the right table.
SELECT c.name
FROM customers c
LEFT JOIN orders o
ON c.customer_id = o.customer_id
WHERE o.customer_id IS NULL;
5. Why can a JOIN produce duplicate-looking rows?
Because of one-to-many or many-to-many relationships between tables.
🎯 Practice Questions
1. Write an INNER JOIN to display customer names and their order IDs.
2. Write a LEFT JOIN to display all customers, including customers who have no orders.
3. Find customers who have never placed an order.
4. Calculate total spending for each customer using JOIN and SUM().
5. Join orders and products and calculate total revenue for each product.
🎯 Key Takeaways
• JOIN combines data from multiple tables.
• INNER JOIN returns matching records.
• LEFT JOIN keeps every record from the left table.
• RIGHT JOIN keeps every record from the right table.
• FULL OUTER JOIN keeps records from both sides.
• CROSS JOIN creates every possible combination.
• SELF JOIN joins a table with itself.
• ON defines the relationship between tables.
• JOINs are fundamental for real-world Data Science and Analytics.
📍 Double Tap ❤️ For More
-----
1.28 ₽ · /balance_helpSELECT c.customer_id,
c.name,
o.order_id
FROM customers c
FULL OUTER JOIN orders o
ON c.customer_id = o.customer_id;
Conceptually:
Customers only
+
Matching records
+
Orders only
Not every SQL database supports FULL OUTER JOIN in the same way, so database-specific syntax matters.
🔹 5. CROSS JOIN
A CROSS JOIN produces every possible combination of rows between two tables.
Suppose:
colors
Red
Blue
sizes
Small
Large
Query:
SELECT color, size
FROM colors
CROSS JOIN sizes;
Result:
Red Small
Red Large
Blue Small
Blue Large
2 colors × 2 sizes = 4 combinations.
This is called a Cartesian product.
Use it carefully because the number of rows can become very large.
🔹 6. SELF JOIN
A SELF JOIN joins a table to itself.
This is useful when rows in the same table have relationships with other rows.
For example, an employee table:
employee_id employee_name manager_id
101 Alice NULL
102 Bob 101
103 Carol 101
You can use a self join to display each employee and their manager:
SELECT e.employee_name AS employee,
m.employee_name AS manager
FROM employees e
LEFT JOIN employees m
ON e.manager_id = m.employee_id;
Result:
employee manager
Alice NULL
Bob Alice
Carol Alice
🔹 JOIN Conditions with ON
The ON clause specifies how the tables should be connected.
ON customers.customer_id = orders.customer_id
This means:
customers.customer_id
=
orders.customer_id
The two columns don't necessarily need to have the same name.
For example:
ON customers.id = orders.customer_id
can also be valid if those columns represent the same relationship.
🔹 Using Table Aliases
Aliases make JOIN queries much easier to read.
Instead of:
SELECT customers.customer_name,
orders.amount
FROM customers
INNER JOIN orders
ON customers.customer_id = orders.customer_id;
You can write:
SELECT c.customer_name,
o.amount
FROM customers c
INNER JOIN orders o
ON c.customer_id = o.customer_id;
Here:
c → customers
o → orders
🔹 JOIN with WHERE
You can filter the joined result.
SELECT c.name,
o.amount
FROM customers c
INNER JOIN orders o
ON c.customer_id = o.customer_id
WHERE o.amount > 1000;
This returns matching customers whose orders exceed 1000.
🔹 JOIN with GROUP BY
You can also aggregate after joining.
Suppose you want total spending by customer:
SELECT c.customer_id,
c.name,
SUM(o.amount) AS total_spent
FROM customers c
INNER JOIN orders o
ON c.customer_id = o.customer_id
GROUP BY c.customer_id, c.name;
This is extremely common in analytics.
🔹 Real-World Data Science Example
Imagine you have three tables:
customers
orders
products
You want to calculate how much revenue each product generated.
You could join the tables:customers
customer_id customer_name
101 Alice
102 Bob
103 Carol
orders
order_id customer_id amount
1 101 500
2 102 800
3 101 300
If you want the customer's name along with their order amount, you need to combine these tables.
This is where JOINS are used.
🔹 What is a JOIN?
A JOIN combines rows from two or more tables using a related column.
SELECT customers.customer_name, orders.amount
FROM customers
JOIN orders
ON customers.customer_id = orders.customer_id;
Result:
customer_name amount
Alice 500
Bob 800
Alice 300
The common column here is:
customer_id
🔹 Why Are JOINS Important?
Data in real organizations is rarely stored in one giant table.
You might have:
Customers
↓
Orders
↓
Products
↓
Payments
↓
Transactions
A Data Scientist or Data Analyst needs to combine these datasets to answer business questions.
Examples:
• Which customers placed orders?
• What products did customers purchase?
• Which regions generated the most revenue?
• Which customers have never placed an order?
• What is the average order value by customer segment?
🔹 Main Types of JOINS
The most important SQL joins are:
1. INNER JOIN
2. LEFT JOIN
3. RIGHT JOIN
4. FULL OUTER JOIN
5. CROSS JOIN
6. SELF JOIN
The first two are especially important for Data Science and Analytics.
🔹 1. INNER JOIN
INNER JOIN returns only rows that have a matching value in both tables.
Example:
customers
customer_id name
101 Alice
102 Bob
103 Carol
orders
order_id customer_id
1 101
2 102
3 104
Query:
SELECT c.customer_id,
c.name,
o.order_id
FROM customers c
INNER JOIN orders o
ON c.customer_id = o.customer_id;
Result:
customer_id name order_id
101 Alice 1
102 Bob 2
Customer 103 has no matching order.
Customer 104 doesn't exist in the customers table.
Therefore, neither appears in the result.
Simple rule:
INNER JOIN → Only matching records
🔹 2. LEFT JOIN
LEFT JOIN returns:
• All rows from the left table
• Matching rows from the right table
If there is no match, the right-side columns contain NULL.
SELECT c.customer_id,
c.name,
o.order_id
FROM customers c
LEFT JOIN orders o
ON c.customer_id = o.customer_id;
Result:
customer_id name order_id
101 Alice 1
102 Bob 2
103 Carol NULL
Carol appears because customers is the left table.
Simple rule:
LEFT JOIN → Everything from left + matching data from right
🔹 Finding Customers Without Orders
This is one of the most useful real-world patterns.
SELECT c.customer_id, c.name
FROM customers c
LEFT JOIN orders o
ON c.customer_id = o.customer_id
WHERE o.customer_id IS NULL;
This identifies customers who have never placed an order.
This type of analysis can be useful for:
• Customer retention
• Marketing campaigns
• Customer segmentation
• Churn analysis
🔹 3. RIGHT JOIN
RIGHT JOIN is essentially the opposite perspective of a LEFT JOIN.
It returns:
• All rows from the right table
• Matching rows from the left table
SELECT c.name,
o.order_id
FROM customers c
RIGHT JOIN orders o
ON c.customer_id = o.customer_id;Customer | Age | Income | Purchase
A | 25 | 40K | Yes
B | 34 | 70K | No
4. Variables
Variables are characteristics or attributes measured in the data.
Examples:
• Age
• Salary
• Department
• Sales
• Customer status
They can be numerical or categorical.
5. Data Collection
Data can come from:
• Databases
• APIs
• Surveys
• Excel files
• Websites
• Applications
• Sensors
• Business systems
Good analysis starts with reliable and relevant data.
6. Data Cleaning
Real-world data is rarely perfect.
Data cleaning involves handling:
• Missing values
• Duplicates
• Incorrect formats
• Invalid values
• Inconsistent categories
• Outliers
Garbage in → garbage out.
7. Missing Values
Missing values occur when information isn't available.
Example:
Customer | Age
A | 25
B | —
C | 31Customer | Age | Income | Purchase
A | 25 | 40K | Yes
B | 34 | 70K | No
4. Variables
Variables are characteristics or attributes measured in the data.
Examples:
• Age
• Salary
• Department
• Sales
• Customer status
They can be numerical or categorical.
5. Data Collection
Data can come from:
• Databases
• APIs
• Surveys
• Excel files
• Websites
• Applications
• Sensors
• Business systems
Good analysis starts with reliable and relevant data.
6. Data Cleaning
Real-world data is rarely perfect.
Data cleaning involves handling:
• Missing values
• Duplicates
• Incorrect formats
• Invalid values
• Inconsistent categories
• Outliers
Garbage in → garbage out.
7. Missing Values
Missing values occur when information isn't available.
Example:
Customer | Age
A | 25
B | —
C | 31SELECT department, COUNT(*) AS employee_count
FROM employees
GROUP BY department
HAVING COUNT(*) > 5;
🔹 Real-World Data Science Example
Suppose you're analyzing customer transactions.
You want customers who have made at least 10 transactions:
SELECT customer_id,
COUNT(*) AS transaction_count
FROM transactions
GROUP BY customer_id
HAVING COUNT(*) >= 10;
This can help identify:
• Frequent customers
• High-engagement users
• Active accounts
• Customers suitable for segmentation
Another example:
Find products generating more than 50000 in revenue:
SELECT product_id,
SUM(quantity * price) AS revenue
FROM sales
GROUP BY product_id
HAVING SUM(quantity * price) > 50000
ORDER BY revenue DESC;
🔹 Interview Questions
1. What is HAVING?
HAVING filters groups created by GROUP BY.
1. What is the difference between WHERE and HAVING?
WHERE filters rows before grouping.
HAVING filters groups after grouping.
1. Can HAVING be used with aggregate functions?
Yes.
HAVING COUNT(*) > 5
1. Can WHERE and HAVING be used together?
Yes.
WHERE salary > 50000
GROUP BY department
HAVING COUNT(*) > 5
1. Why can't we normally use COUNT() in WHERE?
Because WHERE operates on individual rows before the aggregation is performed. HAVING is designed to filter aggregated groups.
🎯 Practice Questions
1. Find departments with more than 10 employees.
2. Find customers who have made at least 5 transactions.
3. Find regions where total sales exceed 100000.
4. Find departments where average salary is greater than 75000.
5. Find products whose total revenue exceeds 50000 and sort them from highest to lowest revenue.
🎯 Key Takeaways
• WHERE → Filters rows.
• GROUP BY → Creates groups.
• HAVING → Filters groups.
• WHERE is applied before grouping.
• HAVING is applied after grouping.
• HAVING is commonly used with COUNT(), SUM(), AVG(), MIN(), and MAX().
• WHERE + GROUP BY + HAVING is one of the most important SQL patterns for analytics.
📍 Double Tap ❤️ For More
-----
1.36 ₽ · /balance_helpSELECT department, COUNT(*) AS employee_count
FROM employees
GROUP BY department;
But if you want only departments with more than 5 employees, use HAVING:
SELECT department, COUNT(*) AS employee_count
FROM employees
GROUP BY department
HAVING COUNT(*) > 5;
The grouping happens first, and then HAVING filters the groups.
🔹 Basic Syntax
SELECT column_name, aggregate_function(column_name)
FROM table_name
GROUP BY column_name
HAVING condition;
🔹 HAVING with COUNT()
Find departments having more than 10 employees:
SELECT department, COUNT(*) AS employee_count
FROM employees
GROUP BY department
HAVING COUNT(*) > 10;
🔹 HAVING with SUM()
Find regions where total sales exceed 100000:
SELECT region, SUM(sales) AS total_sales
FROM sales
GROUP BY region
HAVING SUM(sales) > 100000;
🔹 HAVING with AVG()
Find departments where the average salary is greater than 70000:
SELECT department, AVG(salary) AS avg_salary
FROM employees
GROUP BY department
HAVING AVG(salary) > 70000;
🔹 HAVING with MAX()
Find departments where the highest salary is greater than 150000:
SELECT department, MAX(salary) AS highest_salary
FROM employees
GROUP BY department
HAVING MAX(salary) > 150000;
🔹 WHERE vs HAVING
This is one of the most frequently asked SQL interview questions.
WHERE Filters individual rows.
SELECT *
FROM employees
WHERE salary > 50000;
It removes individual records that don't meet the condition.
HAVING
Filters groups after GROUP BY.
SELECT department, AVG(salary) AS avg_salary
FROM employees
GROUP BY department
HAVING AVG(salary) > 70000;
It removes entire groups that don't meet the condition.
🔹 Using WHERE and HAVING Together
You can use both.
Suppose you want departments where:
• Only employees earning more than 50000 are considered
• The department must have at least 5 such employees
SELECT department, COUNT(*) AS employee_count
FROM employees
WHERE salary > 50000
GROUP BY department
HAVING COUNT(*) >= 5;
Conceptually:
All employees
↓
WHERE
↓
Employees with salary > 50000
↓
GROUP BY
↓
Create department groups
↓
HAVING
↓
Keep groups with at least 5 employees
🔹 HAVING with ORDER BY
You can also sort the filtered groups.
SELECT department, SUM(salary) AS total_salary
FROM employees
GROUP BY department
HAVING SUM(salary) > 500000
ORDER BY total_salary DESC;
This finds departments whose total salary exceeds 500000 and displays the highest totals first.
🔹 HAVING Without GROUP BY
Some SQL databases allow HAVING without an explicit GROUP BY, treating the entire result as a single group.
For example:
SELECT COUNT(*) AS employee_count
FROM employees
HAVING COUNT(*) > 100;
This returns the result only if there are more than 100 employees.
For beginners, however, focus primarily on the common pattern:
GROUP BY → HAVING
🔹 Common Mistake
❌ Incorrect:
SELECT department, COUNT(*)
FROM employees
WHERE COUNT(*) > 5
GROUP BY department;