TGViewer
Data Science & Machine Learning Data Science & Machine Learning @datasciencefun · 77.8K subscribers
Post #4627 2.17K
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
  • ❤ 6
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 →