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
نمایش بیشتر📈 تحلیل کانال تلگرام Data Science & Machine Learning
کانال Data Science & Machine Learning (@datasciencefun) در بخش زبانی انگلیسی بازیگری فعال است. در حال حاضر جامعه شامل 77 616 مشترک است و جایگاه 2 020 را در دسته آموزش و رتبه 3 811 را در منطقه الهند دارد.
📊 شاخصهای مخاطب و پویایی
از زمان ایجاد در невідомо، پروژه رشد سریعی داشته و 77 616 مشترک جذب کرده است.
بر اساس آخرین دادهها در تاریخ 14 نوامبر, 2026، کانال فعالیت پایداری دارد. در ۳۰ روز گذشته تغییر اعضا برابر -147 و در ۲۴ ساعت گذشته برابر -20 بوده و همچنان دسترسی گستردهای حفظ شده است.
- وضعیت تأیید: تأیید نشده
- نرخ تعامل (ER): میانگین تعامل مخاطب 2.41% است و در ۲۴ ساعت نخست پس از انتشار، محتوا معمولاً 0.97% واکنش نسبت به کل مشترکان کسب میکند.
- دسترسی پستها: هر پست به طور میانگین 1 872 بازدید دریافت میکند. در اولین روز معمولاً 755 بازدید جمعآوری میشود.
- واکنشها و تعامل: مخاطبان بهطور فعال حمایت میکنند؛ میانگین واکنش به هر پست 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”
به لطف بهروزرسانیهای پرتکرار (آخرین داده در تاریخ 15 نوامبر, 2026)، کانال همواره بهروز و دارای دسترسی بالاست. تحلیلها نشان میدهد مخاطبان بهطور فعال با محتوا تعامل دارند و آن را به نقطه اثرگذاری مهم در دسته آموزش تبدیل کردهاند.
WITH employee_data AS (
SELECT **
FROM employees
)
SELECT **
FROM employee_data;
View:
CREATE VIEW employee_data AS
SELECT **
FROM employees;
The main difference is that a CTE is temporary within a statement, while a view has a persistent definition in the database.
🔹 9. Real-World Data Science Use Cases
CTEs are widely used in analytical SQL queries to:
• Calculate monthly revenue before comparing sales performance.
• Identify high-value customers.
• Find products with declining sales.
• Calculate department-wise employee statistics.
• Prepare clean datasets for reporting.
• Break complex business queries into smaller steps.
Example: Find customers whose total spending is greater than 50,000.
WITH customer_spending AS (
SELECT
customer_id,
SUM(amount) AS total_spending
FROM orders
GROUP BY customer_id
)
SELECT
customer_id,
total_spending
FROM customer_spending
WHERE total_spending > 50000;
This is useful for customer segmentation and identifying high-value customers.
🔹 10. Common Mistakes to Avoid
• Forgetting the WITH keyword.
• Forgetting parentheses around the CTE query.
• Missing commas between multiple CTE definitions.
• Referencing a CTE outside the SQL statement where it is defined.
• Assuming a CTE permanently stores data.
• Giving CTEs unclear names.
• Assuming CTEs always improve query performance.
Important: A CTE improves query organization and readability, but it does not automatically make a query faster. Its execution behavior depends on the database system and query optimizer.
🔹 11. SQL Interview Questions
Q1. What is a CTE in SQL?
A CTE is a temporary named result set defined using the WITH keyword and used within a single SQL statement.
Q2. Which keyword is used to create a CTE?
The WITH keyword.
Q3. Can we create multiple CTEs in one query?
Yes. Multiple CTEs can be defined in a single WITH clause, separated by commas.
Q4. What is the difference between a CTE and a view?
A CTE exists only for one SQL statement, whereas a view is a stored database object that can be reused across queries.
Q5. Do CTEs improve query performance?
Not necessarily. CTEs mainly improve readability and organization. Performance depends on the database optimizer and query structure.
🎯 Practice Questions
Try writing SQL queries for these problems:
• Create a CTE to find employees earning more than 60,000.
• Calculate department-wise average salary using a CTE.
• Find customers whose total spending exceeds 50,000.
• Create two CTEs to calculate and filter product sales.
• Use a CTE with JOIN to display customer names and their total orders.
🎯 Key Takeaways
• CTE stands for Common Table Expression.
• CTEs are created using the WITH keyword.
• They make complex SQL queries easier to understand.
• You can create multiple CTEs in one query.
• CTEs can be used with JOIN, GROUP BY, and WHERE.
• A CTE exists only within its SQL statement.
• CTEs and views are different.
• CTEs improve readability but do not guarantee better performance.
Double Tap ❤️ For More
-----
0.997056 ₽ · /balance_helpSELECT **
FROM employees
WHERE salary > (
SELECT AVG(salary)
FROM employees
);
Equivalent approach using a CTE:
WITH average_salary AS (
SELECT AVG(salary) AS avg_salary
FROM employees
)
SELECT **
FROM employees
WHERE salary > (
SELECT avg_salary
FROM average_salary
);
Both approaches solve the same problem.
🔹 8. CTE vs View
Another important interview concept.WITH department_salary AS (
SELECT
department,
AVG(salary) AS average_salary
FROM employees
GROUP BY department
)
SELECT **
FROM department_salary
WHERE average_salary > 70000;
🔹 5. Using Multiple CTEs
You can create multiple CTEs within a single SQL query. This is especially useful when solving complex business problems step by step.
Suppose you want to:
• Calculate total sales by product.
• Find products generating more than 1,00,000 in sales.
WITH product_sales AS (
SELECT
product_id,
SUM(amount) AS total_sales
FROM orders
GROUP BY product_id
),
high_sales_products AS (
SELECT **
FROM product_sales
WHERE total_sales > 100000
)
SELECT **
FROM high_sales_products;
• The first CTE calculates total sales.
• The second CTE filters high-performing products.
• The final query retrieves the result.
Important: Separate multiple CTE definitions with commas.
🔹 6. CTE with JOIN
You can combine CTEs with JOIN operations.
Example: Find total sales generated by each customer.
Suppose you have:
• customers
• orders
WITH customer_sales AS (
SELECT
customer_id,
SUM(amount) AS total_sales
FROM orders
GROUP BY customer_id
)
SELECT
c.customer_name,
cs.total_sales
FROM customers c
INNER JOIN customer_sales cs
ON c.customer_id = cs.customer_id;
The CTE calculates total sales for each customer. The main query joins that result with the customers table to retrieve customer names.
🔹 7. CTE vs Subquery
This is a common SQL interview question.SELECT employee_name, salary
FROM employees
WHERE salary > 60000;
Using a CTE:
WITH high_salary_employees AS (
SELECT employee_name, salary
FROM employees
WHERE salary > 60000
)
SELECT **
FROM high_salary_employees;
Here:
• The CTE is created using WITH.
• The inner query selects employees earning more than 60,000.
• The outer query retrieves the result from the CTE.
🔹 2. Basic Syntax of a CTE
WITH cte_name AS (
SELECT column1, column2
FROM table_name
WHERE condition
)
SELECT **
FROM cte_name;
Important parts:
• WITH starts the CTE.
• cte_name is the name you give to the temporary result.
• AS introduces the query.
• The query inside parentheses defines the CTE.
• The main query uses the CTE.
🔹 3. CTE with WHERE Condition
You can use CTEs to filter records before applying further conditions.
Example: Find employees earning more than 50,000 and display only those earning more than 70,000.
WITH employee_data AS (
SELECT employee_name, salary
FROM employees
WHERE salary > 50000
)
SELECT **
FROM employee_data
WHERE salary > 70000;
The CTE first selects employees earning above 50,000. The outer query further filters the result.
🔹 4. CTE with GROUP BY
CTEs are very useful when working with aggregate functions.
Example: Calculate the average salary for each department.
WITH department_salary AS (
SELECT
department,
AVG(salary) AS average_salary
FROM employees
GROUP BY department
)
SELECT **
FROM department_salary;
Result: