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 741 مشترک است و جایگاه 2 010 را در دسته آموزش و رتبه 3 917 را در منطقه الهند دارد.
📊 شاخصهای مخاطب و پویایی
از زمان ایجاد در невідомо، پروژه رشد سریعی داشته و 77 741 مشترک جذب کرده است.
بر اساس آخرین دادهها در تاریخ 25 اکتبر, 2026، کانال فعالیت پایداری دارد. در ۳۰ روز گذشته تغییر اعضا برابر 175 و در ۲۴ ساعت گذشته برابر 0 بوده و همچنان دسترسی گستردهای حفظ شده است.
- وضعیت تأیید: تأیید نشده
- نرخ تعامل (ER): میانگین تعامل مخاطب 2.75% است و در ۲۴ ساعت نخست پس از انتشار، محتوا معمولاً 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 column1, column2
FROM table_name
ORDER BY column_name;
By default, SQL sorts in ascending order.
SELECT *
FROM employees
ORDER BY salary;
This generally returns employees from the lowest salary to the highest salary.
🔹 ASC — Ascending Order
ASC means ascending.
SELECT *
FROM employees
ORDER BY salary ASC;
For numbers: 10000, 25000, 40000, 75000, 100000
For text: Amazon, Apple, Google, Microsoft
For dates: 2024-01-01, 2024-05-15, 2024-12-20, 2025-03-10
ASC is usually the default, so ORDER BY salary; is equivalent to ORDER BY salary ASC;
🔹 DESC — Descending Order
DESC means descending.
SELECT *
FROM employees
ORDER BY salary DESC;
Example: 100000, 75000, 40000, 25000, 10000
This is especially useful when you want to find:
• Highest-paid employees
• Top-selling products
• Most expensive products
• Most recent transactions
• Highest-performing regions
🔹 Sorting Text
You can sort text columns alphabetically.
SELECT employee_name, department
FROM employees
ORDER BY employee_name ASC;
SELECT employee_name, department
FROM employees
ORDER BY employee_name DESC;
🔹 Sorting Dates
To find the most recent transactions:
SELECT transaction_id, transaction_date, amount
FROM transactions
ORDER BY transaction_date DESC;
To see transactions from oldest to newest:
SELECT transaction_id, transaction_date, amount
FROM transactions
ORDER BY transaction_date ASC;
🔹 Sorting by Multiple Columns
This is very important. Suppose you want to sort employees:
1. By department
2. Within each department, by salary from highest to lowest
SELECT employee_name, department, salary
FROM employees
ORDER BY department ASC, salary DESC;
SQL first sorts by department. When multiple rows have the same department, it then uses salary to determine their order.
Example:
Finance 90000
Finance 70000
Finance 50000
HR 85000
HR 60000
IT 120000
IT 95000
🔹 ORDER BY with Calculations
You can also sort using an expression.
SELECT product_name, quantity, price,
quantity * price AS total_value
FROM products
ORDER BY quantity * price DESC;
You can also use the alias in many SQL databases:
SELECT product_name,
quantity * price AS total_value
FROM products
ORDER BY total_value DESC;
🔹 ORDER BY with DISTINCT
SELECT DISTINCT department
FROM employees
ORDER BY department ASC;
This returns each department once and sorts them alphabetically.
🔹 ORDER BY and NULL Values
NULL represents a missing or unknown value. The position of NULL values when using ORDER BY can vary between SQL databases.
Some databases also support explicit control such as:
ORDER BY salary ASC NULLS LAST;
or
ORDER BY salary DESC NULLS FIRST;
Always check the syntax supported by your SQL database.
🔹 ORDER BY with WHERE
WHERE filters the rows first, and ORDER BY sorts the resulting rows.
SELECT employee_name, salary
FROM employees
WHERE department = 'IT'
ORDER BY salary DESC;WHERE city = Pune;
Correct:
WHERE city = 'Pune';
❌ Mistake 3: Using AND when you mean OR
Incorrect if you want either city:
WHERE city = 'Pune'
AND city = 'Mumbai';
A single city value cannot normally be both at the same time.
Correct:
WHERE city = 'Pune'
OR city = 'Mumbai';
Or:
WHERE city IN ('Pune', 'Mumbai');
❌ Mistake 4: Forgetting parentheses
For complex conditions, use parentheses:
WHERE
(city = 'Pune' OR city = 'Mumbai')
AND age > 30;
❌ Mistake 5: Assuming BETWEEN excludes the boundaries
BETWEEN is generally inclusive.
🔹 34. Interview Questions
💡 What is the purpose of WHERE?
WHERE filters rows based on a condition.
💡 What is the difference between WHERE and SELECT?
SELECT → Determines what columns/expressions appear in the result.
WHERE → Determines which rows are included.
💡 How do you check for NULL?
Use:
IS NULL
or:
IS NOT NULL
💡 What is the difference between IN and OR?
IN provides a concise way to test whether a value matches any value in a list.
💡 Is BETWEEN inclusive?
Yes, BETWEEN generally includes both boundary values.
🎯 Practice Questions
Q1. Write a query to retrieve employees whose salary is greater than 50,000.
Q2. Write a query to retrieve customers from Pune or Mumbai.
Q3. Write a query to retrieve products priced between 1,000 and 5,000.
Q4. Write a query to retrieve customers whose phone number is missing.
Q5. Write a query to retrieve orders where the status is Success and the amount is greater than 10,000.
🎯 Key Takeaways
✅ WHERE is used to filter rows.
✅ = checks equality.
✅ <> and != can be used for not equal.
✅ AND requires all specified conditions to be true.
✅ OR requires at least one condition to be true.
✅ IN is useful for matching multiple values.
✅ BETWEEN is useful for ranges and is generally inclusive.
✅ LIKE is used for pattern matching.
✅ % represents a sequence of characters.
✅ _ represents one character.
✅ Use IS NULL and IS NOT NULL for NULL values.
✅ Parentheses make complex AND/OR logic clearer and safer.
🧭 Double Tap ❤️ For More
-----
3 ₽ · /balance_helpSELECT *
FROM customers
WHERE city IN ('Pune', 'Mumbai', 'Delhi');
IN checks whether a value belongs to a specified list.
🔹 23. NOT IN
You can also exclude multiple values.
SELECT *
FROM customers
WHERE city NOT IN ('Pune', 'Mumbai');
This returns customers whose city isn't Pune or Mumbai.
🔹 24. LIKE
LIKE is used for pattern matching.
Suppose we want names beginning with A.
SELECT *
FROM customers
WHERE name LIKE 'A%';
Here:
% → Any sequence of characters
So this could match:
Alice
Amit
Ananya
🔹 25. LIKE with %
Example:
SELECT *
FROM customers
WHERE name LIKE '%an%';
This searches for names containing the sequence an.
The exact behavior can depend on database collation and case-sensitivity settings.
🔹 26. LIKE with _
The underscore _ generally represents exactly one character.
Example:
SELECT *
FROM products
WHERE product_code LIKE 'A_1';
This could match:
A11
AB1
AX1
But not:
A123
A1
because _ represents one character.
🔹 27. NULL Values
One of the most important concepts in SQL filtering is NULL.
NULL generally means:
Missing, unknown, or unavailable value.It does not mean: Zero Empty string False For example: customer_id name phone 101 Alice 9999999999 102 Bob NULL Bob's phone number is missing or unknown. 🔹 28. Checking for NULL You should not normally write:
WHERE phone = NULL
Instead, use:
SELECT *
FROM customers
WHERE phone IS NULL;
To find records where the value exists:
SELECT *
FROM customers
WHERE phone IS NOT NULL;
This is extremely important in Data Analytics.
🔹 29. WHERE and NULL Logic
Suppose:
WHERE salary > 50000
What happens when salary is NULL?
The condition isn't considered true.
The row won't be returned.
SQL uses three-valued logic involving:
TRUE
FALSE
UNKNOWN
This is one reason NULL handling requires special attention.
🔹 30. WHERE with SELECT
WHERE works together with SELECT.
Example:
SELECT
customer_id,
name,
city
FROM customers
WHERE city = 'Pune';
The query:
1.
Retrieves selected columns
2.
From the customers table
3.
Keeps only rows satisfying the condition
🔹 31. WHERE in Real-World Data Science
Imagine a transaction database containing millions of records.
A Data Scientist needs:
Successful transactions above ₹10,000 from January 2026 onward.A query might look like:
SELECT
transaction_id,
customer_id,
transaction_date,
amount
FROM transactions
WHERE status = 'Success'
AND amount > 10000
AND transaction_date >= '2026-01-01';
This is much more efficient for analysis than extracting the entire table and filtering everything later in Python.
🔹 32. WHERE Before Python
A common Data Science workflow is:
Database → SQL → Filter/Transform → Python → Analysis → Model
For example:
SELECT
customer_id,
amount,
transaction_date
FROM transactions
WHERE status = 'Success';
Then load the result into Pandas:
import pandas as pd
df = pd.read_sql(query, connection)
SQL handles the database-side filtering, while Python can then handle deeper analysis.
🔹 33. Common Mistakes
❌ Mistake 1: Using = with NULL
Incorrect:
WHERE phone = NULL;
Correct:
WHERE phone IS NULL;SELECT *
FROM customers
WHERE city = 'Pune'
OR city = 'Mumbai';
This returns customers from either Pune or Mumbai.
🔹 14. AND vs OR
Consider:
WHERE age > 30
AND city = 'Pune'
A customer must satisfy both conditions.
But:
WHERE age > 30
OR city = 'Pune'
A customer only needs to satisfy one or both conditions.
This difference is extremely important.
🔹 15. NOT
NOT reverses a condition.
Example:
SELECT *
FROM customers
WHERE NOT city = 'Pune';
This returns customers who aren't from Pune.
You can also commonly write:
SELECT *
FROM customers
WHERE city <> 'Pune';
🔹 16. Combining AND and OR
You can combine multiple logical operators.
Example:
SELECT *
FROM employees
WHERE department = 'Finance'
AND salary > 60000;
Another example:
SELECT *
FROM employees
WHERE department = 'Finance'
OR department = 'Analytics'
AND salary > 60000;
When conditions become complex, use parentheses to make your intended logic explicit.
For example:
SELECT *
FROM employees
WHERE
(department = 'Finance' OR department = 'Analytics')
AND salary > 60000;
This means:
Employees from Finance or Analytics who earn more than 60,000.🔹 17. Why Parentheses Matter Consider:
WHERE city = 'Pune'
OR city = 'Mumbai'
AND age > 30
SQL's logical evaluation rules can make this behave differently from what a beginner might expect.
A safer and clearer version is:
WHERE
(city = 'Pune' OR city = 'Mumbai')
AND age > 30;
This clearly communicates the intended logic.
Best practice:
Use parentheses whenever combining AND and OR in a complex condition.🔹 18. WHERE with Dates You can also filter dates. Example:
SELECT *
FROM orders
WHERE order_date >= '2026-01-01';
This retrieves orders on or after January 1, 2026.
Another example:
SELECT *
FROM orders
WHERE order_date < '2026-07-01';
This retrieves orders before July 1, 2026.
Date syntax can vary slightly across database systems, so always consider the SQL dialect you're using.
🔹 19. Filtering a Date Range
Suppose you want orders during a particular period.
You can use:
SELECT *
FROM orders
WHERE order_date >= '2026-01-01'
AND order_date < '2026-04-01';
This retrieves orders from January through March.
Using a half-open range like this is particularly useful when working with timestamps because it avoids accidentally excluding records with time components.
🔹 20. BETWEEN
SQL provides BETWEEN for range filtering.
Example:
SELECT *
FROM products
WHERE price BETWEEN 1000 AND 5000;
BETWEEN is inclusive of both boundaries in standard SQL.
So this includes:
1000
and:
5000
as well as values between them.
🔹 21. BETWEEN with Dates
Example:
SELECT *
FROM orders
WHERE order_date BETWEEN '2026-01-01' AND '2026-01-31';
For a date-only column, this can be useful.
However, if order_date contains timestamps, using:
order_date >= '2026-01-01'
AND order_date < '2026-02-01'
is often safer because it includes the entire final day regardless of the timestamp.
🔹 22. IN Operator
Suppose you want customers from:
Pune
Mumbai
Delhi
You could write:
SELECT *
FROM customers
WHERE city = 'Pune'
OR city = 'Mumbai'
OR city = 'Delhi';SELECT column1, column2
FROM table_name
WHERE condition;
Example:
SELECT *
FROM customers
WHERE city = 'Mumbai';
This returns only customers whose city is Mumbai.
🔹 2. WHERE with Text Values
Text values are generally written inside single quotes.
Example:
SELECT customer_id, name
FROM customers
WHERE city = 'Pune';
This retrieves customers from Pune.
Another example:
SELECT *
FROM employees
WHERE department = 'Finance';
🔹 3. WHERE with Numbers
For numeric values, quotes are generally not required.
Example:
SELECT *
FROM customers
WHERE age > 30;
This returns customers older than 30.
Another example:
SELECT *
FROM orders
WHERE amount > 10000;
This returns orders where the amount is greater than 10,000.
🔹 4. Comparison Operators
The most commonly used comparison operators are:
Operator Meaning
= Equal to
<> Not equal to
!= Not equal to
Greater than < Less than = Greater than or equal to <= Less than or equal toExample:
SELECT *
FROM employees
WHERE salary >= 50000;
This returns employees whose salary is at least 50,000.
🔹 5. Equal To =
The = operator checks whether two values are equal.
SELECT *
FROM customers
WHERE city = 'Delhi';
Only records where city equals Delhi are returned.
🔹 6. Not Equal <>
You can retrieve records that don't match a value.
SELECT *
FROM customers
WHERE city <> 'Delhi';
This returns customers whose city isn't Delhi.
You may also see:
WHERE city != 'Delhi'
Both are commonly supported, although <> is the standard SQL operator.
🔹 7. Greater Than >
Example:
SELECT *
FROM orders
WHERE amount > 50000;
Returns orders above 50,000.
🔹 8. Less Than <
Example:
SELECT *
FROM products
WHERE price < 1000;
Returns products priced below 1,000.
🔹 9. Greater Than or Equal To >=
Example:
SELECT *
FROM employees
WHERE experience >= 5;
This includes employees with exactly 5 years as well as those with more than 5 years.
🔹 10. Less Than or Equal To <=
Example:
SELECT *
FROM products
WHERE price <= 500;
This includes products priced exactly at 500.
🔹 11. WHERE with Multiple Conditions
Real-world queries often require more than one condition.
For this, SQL provides logical operators:
• AND
• OR
• NOT
🔹 12. AND
AND means all conditions must be true.
Example:
SELECT *
FROM customers
WHERE city = 'Pune'
AND age > 30;
This returns customers who:
1.
Are from Pune
2.
Are older than 30
Both conditions must be satisfied.
🔹 13. OR
OR means at least one condition must be true.
Example:order_id | customer_id | product | price
1 | 101 | Laptop | 60000
2 | 102 | Phone | 30000
3 | 101 | Mouse | 1000
To retrieve order details:
SELECT
order_id,
customer_id,
product,
price
FROM orders;
To calculate price after adding a hypothetical 10% increase:
SELECT
product,
price,
price * 1.10 AS increased_price
FROM orders;
🔹 21. SELECT in Real-World Data Science
SQL is often the first step in a Data Science workflow.
For example:
Business Question
"Give me all customer transactions from the sales database."
You might start with:
SELECT
customer_id,
order_date,
product_id,
amount
FROM transactions;
Then later:
WHERE → Filter data
GROUP BY → Aggregate data
JOIN → Combine tables
ORDER BY → Sort results
Window Functions → Advanced analysis
Eventually, you may load the SQL result into Pandas:
import pandas as pd
df = pd.read_sql(query, connection)
So SQL and Python often work together.
🔹 22. Common Beginner Mistakes
❌ Mistake 1: Forgetting the FROM clause
Incorrect:
SELECT name;
when you intend to retrieve a column from a table.
Correct:
SELECT name
FROM customers;
❌ Mistake 2: Using commas incorrectly
Correct:
SELECT name, city, age
FROM customers;
❌ Mistake 3: Confusing column names and values
A column:
city
is different from a text value:
'Pune'
We'll explore this more when we learn WHERE.
❌ Mistake 4: Using SELECT * everywhere
SELECT * is useful while learning and exploring, but for production queries, selecting only the required columns can be more efficient and clearer.
🔹 23. Interview Questions
💡 What does SELECT do?
SELECT specifies the columns or expressions that should appear in the query result.
💡 What does SELECT * mean?
It selects all columns from the specified table.
💡 What is an alias?
An alias gives a temporary name to a column or expression in the query result.
💡 What does DISTINCT do?
It removes duplicate rows from the selected result.
🎯 Practice Questions
Q1. Write a query to select all columns from a table called employees.
Q2. Write a query to select only employee_id and salary from employees.
Q3. Write a query to display salary as monthly_salary.
Q4. Write a query to calculate price * quantity as total_amount from an orders table.
Q5. Write a query to return unique values from the department column of an employees table.
🎯 Key Takeaways
✅ SQL is used to communicate with relational databases.
✅ SELECT specifies what you want to retrieve.
✅ FROM specifies the table.
✅ * means all columns.
✅ You can select one or multiple columns.
✅ AS creates a temporary alias.
✅ SQL can perform calculations.
✅ DISTINCT returns unique results.
✅ SQL is one of the most important tools for extracting data before analysis and Machine Learning.
🧭 Double Tap ❤️ For More
-----
1.57 ₽ · /balance_help