TGViewer
Data Science & Machine Learning Data Science & Machine Learning @datasciencefun ยท 77.7K subscribers
Post #4631 1.05K
๐Ÿš€ Data Science Roadmap 2026

**

๐Ÿ“ Phase 3: SQL for Data Science**

๐Ÿ“– Topic 2: SQL Basics โ€” WHERE

After learning SELECT, the next essential SQL concept is WHERE.

In real-world Data Science, databases can contain millions or billions of records. You usually don't want to retrieve everything.

You want to answer questions such as:

Which customers are from Mumbai?

Which orders are above โ‚น10,000?

Which employees joined after 2023?

Which transactions were successful?

Which products belong to a particular category?

The WHERE clause allows you to filter rows based on conditions.

๐Ÿ”น 1. What Is WHERE?

WHERE is used to filter records based on a specified condition.

Basic syntax:

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 to



Example:

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:
  • โค 1
More from @datasciencefun
  1. Oct 2, 2026Data Visualisation tips for beginners
  2. Sep 29, 2026๐—™๐—ฅ๐—˜๐—˜ ๐—ฅ๐—ฒ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€ ๐—ง๐—ผ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐—”๐—œ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ๐Ÿš€ โ€‹ Explore 6 free resourceโ€ฆ
  3. Sep 28, 2026๐Ÿ”น Real-World Data Science Example Suppose you are analyzing sales data. You want to identโ€ฆ
  4. Sep 28, 2026๐Ÿš€ Data Science Roadmap 2026 ๐Ÿ“ Phase 3: SQL for Data Science ๐Ÿ“– Topic 3 โ€” ORDER BY ORDERโ€ฆ
  5. Sep 28, 2026๐ŸŽ“ ๐—›๐—”๐—ฅ๐—ฉ๐—”๐—ฅ๐—— ๐—จ๐—ก๐—œ๐—ฉ๐—˜๐—ฅ๐—ฆ๐—œ๐—ง๐—ฌ ๐—™๐—ฅ๐—˜๐—˜ ๐—ข๐—ก๐—Ÿ๐—œ๐—ก๐—˜ ๐—–๐—ข๐—จ๐—ฅ๐—ฆ๐—˜๐—ฆ ๐Ÿ˜ Dreaming ofโ€ฆ
  6. Sep 27, 2026Complete Data Analytics Mastery: From Basics to Advanced ๐Ÿš€ Begin your Data Analytics jourโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’