Data Science & Machine Learning
77.8K subscribers
898 photos
1 video
68 files
817 links
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
Download Telegram
Which clause filters rows before GROUP BY?
Anonymous Quiz
22%
A) HAVING
33%
B) ORDER BY
41%
C) WHERE
3%
D) LIMIT
โค1
What does this query return?
SELECT department, SUM(salary) AS total_salary
FROM employees GROUP BY department;
Anonymous Quiz
12%
A) The highest salary in each department
13%
B) The average salary in each department
70%
C) The total salary for each department
5%
D) The number of employees in each department
โค2
๐——๐—ฎ๐˜๐—ฎ ๐˜€๐—ฐ๐—ถ๐—ฒ๐—ป๐—ฐ๐—ฒ ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ช๐—ถ๐˜๐—ต ๐—”๐—œ๐Ÿ˜

Future Ready Data Science and AI Skills You Build

->Build Python, Machine Learning, and AI Skills
->Get Mentored by Industry Experts
->Practice with Mock Interviews
->Ace Your Placements & Land Dream Tech Job

๐Ÿค 500+ Partner Companies |๐ŸŽ“ 2000+ Students Placed

๐Ÿ”— ๐—ฅ๐—ฒ๐—ด๐—ถ๐˜€๐˜๐—ฒ๐—ฟ ๐—ก๐—ผ๐˜„ ๐Ÿ‘‡ :-

https://pdlink.in/47pezFz

๐Ÿ“ฒ Save & Share with Friends Preparing for Data Science & AI Jobs!
โค3
๐—œ๐—•๐—  ๐—™๐—ฅ๐—˜๐—˜ ๐—ง๐—˜๐—–๐—› ๐—–๐—ข๐—จ๐—ฅ๐—ฆ๐—˜๐—ฆ ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ! ๐ŸŽ“

Explore IBM Cognitive Class and build in-demand tech skills without spending money on course fees!

๐Ÿ“š ๐—ง๐—ผ๐—ฝ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐˜๐—ผ ๐—˜๐˜…๐—ฝ๐—น๐—ผ๐—ฟ๐—ฒ:-

๐Ÿ’ซ Artificial Intelligence & Machine Learning
๐Ÿ”ฅPython for Data Science
๐Ÿ“Š Data Science Fundamentals
โ˜๏ธ Cloud Computing & Big Data

๐Ÿ”— ๐—ฆ๐˜๐—ฎ๐—ฟ๐˜ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป๐—ถ๐—ป๐—ด ๐—›๐—ฒ๐—ฟ๐—ฒ ๐Ÿ‘‡

https://pdlink.in/4zGswuX

๐Ÿ“ฒ Save & Share with friends preparing for tech careers! ๐Ÿ”ฅ
โค2
๐Ÿš€ Data Science Roadmap 2026

๐Ÿ“ Phase 3: SQL for Data Science

๐Ÿ“– Topic 7 โ€” HAVING

HAVING is used to filter grouped results.

The most important thing to remember:

WHERE โ†’ filters rows

HAVING โ†’ filters groups

๐Ÿ”น Why Do We Need HAVING?

Suppose you want to find departments that have more than 5 employees.

First, you need to group employees by department:

SELECT 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;
โค2
Aggregate functions such as COUNT() generally cannot be used in WHERE.

โœ… Correct:

SELECT 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

What is HAVING?

HAVING filters groups created by GROUP BY.


What is the difference between WHERE and HAVING?

WHERE filters rows before grouping.

HAVING filters groups after grouping.


Can HAVING be used with aggregate functions?

Yes.

HAVING COUNT(*) > 5


Can WHERE and HAVING be used together?

Yes.

WHERE salary > 50000
GROUP BY department
HAVING COUNT(*) > 5


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
โค7
๐Ÿฐ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐—ง๐—ผ ๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—–๐—ผ๐—ฑ๐—ถ๐—ป๐—ด ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜๐Ÿ˜

โœ… 100% FREE YouTube Learning
โœ… Beginner-Friendly Programming Tutorials
โœ… Learn Popular & In-Demand Tech Skills
โœ… Study at Your Own Pace
โœ… Build a Strong Foundation for Coding Interviews

๐Ÿ”— ๐—”๐—ฐ๐—ฐ๐—ฒ๐˜€๐˜€ ๐—”๐—Ÿ๐—Ÿ ๐Ÿฐ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐Ÿ‘‡:-

https://pdlink.in/3WcuMvi

โšก Your coding journey can start todayโ€”completely FREE!
โค2๐Ÿ˜1
๐—ง๐—”๐—ง๐—” ๐—™๐—ฅ๐—˜๐—˜ ๐— ๐—œ๐—–๐—ฅ๐—ข-๐—œ๐—ก๐—ง๐—˜๐—ฅ๐—ก๐—ฆ๐—›๐—œ๐—ฃ๐—ฆ ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ! ๐ŸŽ“

โœ… 100% FREE Learning Experience
โœ… Short Programs โ€” Approximately 4โ€“6 Hours
โœ… Practical, Real-World Tasks
โœ… Self-Paced & Online
โœ… Certificate Opportunities for Your Resume & LinkedIn
โœ… No Traditional Interview Process

๐Ÿ”— ๐—˜๐˜…๐—ฝ๐—น๐—ผ๐—ฟ๐—ฒ ๐—ง๐—”๐—ง๐—” ๐—™๐—ฅ๐—˜๐—˜ ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ-๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐—ป๐˜€๐—ต๐—ถ๐—ฝ๐˜€๐Ÿ‘‡:-

https://pdlink.in/4yWgaPn

โšก Don't wait for your first job to start gaining practical experience!
โค2
๐ŸŽฏ Tech Career Tracks What Youโ€™ll Work With ๐Ÿš€๐Ÿ‘จโ€๐Ÿ’ป

๐Ÿ’ก 1. Data Scientist
โ–ถ๏ธ Languages: Python, R
โ–ถ๏ธ Skills: Statistics, Machine Learning, Data Wrangling
โ–ถ๏ธ Tools: Pandas, NumPy, Scikit-learn, Jupyter
โ–ถ๏ธ Projects: Predictive models, sentiment analysis, dashboards

๐Ÿ“Š 2. Data Analyst
โ–ถ๏ธ Tools: Excel, SQL, Tableau, Power BI
โ–ถ๏ธ Skills: Data cleaning, Visualization, Reporting
โ–ถ๏ธ Languages: Python (optional)
โ–ถ๏ธ Projects: Sales reports, business insights, KPIs

๐Ÿค– 3. Machine Learning Engineer
โ–ถ๏ธ Core: ML Algorithms, Model Deployment
โ–ถ๏ธ Tools: TensorFlow, PyTorch, MLflow
โ–ถ๏ธ Skills: Feature engineering, model tuning
โ–ถ๏ธ Projects: Image classifiers, recommendation systems

๐ŸŒ 4. Cloud Engineer
โ–ถ๏ธ Platforms: AWS, Azure, GCP
โ–ถ๏ธ Tools: Terraform, Ansible, Docker, Kubernetes
โ–ถ๏ธ Skills: Cloud architecture, networking, automation
โ–ถ๏ธ Projects: Scalable apps, serverless functions

๐Ÿ” 5. Cybersecurity Analyst
โ–ถ๏ธ Concepts: Network Security, Vulnerability Assessment
โ–ถ๏ธ Tools: Wireshark, Burp Suite, Nmap
โ–ถ๏ธ Skills: Threat detection, penetration testing
โ–ถ๏ธ Projects: Security audits, firewall setup

๐Ÿ•น๏ธ 6. Game Developer
โ–ถ๏ธ Languages: C++, C#, JavaScript
โ–ถ๏ธ Engines: Unity, Unreal Engine
โ–ถ๏ธ Skills: Physics, animation, design patterns
โ–ถ๏ธ Projects: 2D/3D games, multiplayer games

๐Ÿ’ผ 7. Tech Product Manager
โ–ถ๏ธ Skills: Agile, Roadmaps, Prioritization
โ–ถ๏ธ Tools: Jira, Trello, Notion, Figma
โ–ถ๏ธ Background: Business + basic tech knowledge
โ–ถ๏ธ Projects: MVPs, user stories, stakeholder reports

๐Ÿ’ฌ Pick a track โ†’ Learn tools โ†’ Build + share projects โ†’ Grow your brand

โค๏ธ Tap for more!
โค6๐Ÿ‘4
๐— ๐—œ๐—–๐—ฅ๐—ข๐—ฆ๐—ข๐—™๐—ง ๐—™๐—ฅ๐—˜๐—˜ ๐——๐—”๐—ง๐—” ๐—ฆ๐—–๐—œ๐—˜๐—ก๐—–๐—˜ ๐—ฅ๐—˜๐—ฆ๐—ข๐—จ๐—ฅ๐—–๐—˜๐—ฆ ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ! ๐ŸŽ“

Microsoft offers valuable FREE learning resources to help you develop in-demand technical skills! ๐Ÿ’ป

โœ… 100% FREE Learning Resources
โœ… Beginner-Friendly Tutorials
โœ… Self-Paced Learning
โœ… Practical Skills for Real-World Projects
โœ… Useful for Data Analytics & Data Science Career Preparation

๐Ÿ”— ๐—”๐—ฐ๐—ฐ๐—ฒ๐˜€๐˜€ ๐—”๐—Ÿ๐—Ÿ ๐Ÿฐ ๐—™๐—ฅ๐—˜๐—˜ ๐—ฅ๐—ฒ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€ ๐Ÿ‘‡:-

https://pdlink.in/4k6ylNq

โšก Your Data Science journey can start today โ€” completely FREE!
โค4
๐——๐—ฎ๐˜๐—ฎ ๐—ฆ๐—ฐ๐—ถ๐—ฒ๐—ป๐—ฐ๐—ฒ & ๐— ๐—ฎ๐—ฐ๐—ต๐—ถ๐—ป๐—ฒ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป๐—ถ๐—ป๐—ด ๐—™๐—ฅ๐—˜๐—˜ ๐—ข๐—ป๐—น๐—ถ๐—ป๐—ฒ ๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ๐—ฐ๐—น๐—ฎ๐˜€๐˜€ ๐Ÿ“Š

Build a strong foundation in Data Science .Explore Machine Learning and Deep Learning

Eligibility :- Students โ€ข Freshers โ€ข Working Professionals

๐Ÿ“… Date:- 23 October 2026
โฐ Time:- 7:00 PMโ€“9:00 PM IST
๐Ÿ’ป Mode:- Online

๐Ÿ”— ๐—ฅ๐—ฒ๐—ด๐—ถ๐˜€๐˜๐—ฒ๐—ฟ ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜๐Ÿ‘‡ :-

https://pdlink.in/4i8MKGn

๐Ÿ“ข Share this opportunity with your friends and classmates.
โค1
๐Ÿ—บ๏ธ 6 stops to a data career.

Generative AI โ†’ Spreadsheets โ†’ SQL โ†’ AI assistants & agents โ†’ Python โ†’ Machine Learning. Then a capstone on your own dataset.

Join Foundations of Data Science and AIML by iHUB Anubhuti IIITD Foundation.

โœ… 4 Months | Online | 6-8 hrs/week
โœ… Learn Python, SQL, Excel & AI tools
โœ… Certified by iHUB Anubhuti IIITD Foundation and Masai
โœ… Campus immersion at iHUB Anubhuti IIITD Foundation
โœ… Placement assistance for 1 year by Masai

๐Ÿ“… Qualifier Test: 25th Oct
Test fee: โ‚น49 | Eligibility: 12th pass and above

๐Ÿ”— https://tinyurl.com/aff-iiitd-aiml