TGViewer
Data Science & Machine Learning Data Science & Machine Learning @datasciencefun · 77.8K subscribers
Post #4653 229
ORDER BY salary DESC
LIMIT 5;


Mistake 3 — Forgetting that LIMIT applies after sorting

For a top-N analysis, think:

ORDER BY → LIMIT

not simply:

LIMIT → assume top records

🔹 Interview Questions

1. What is LIMIT?

LIMIT restricts the number of rows returned by a query.

2. How do you find the top 10 salaries?

SELECT *
FROM employees
ORDER BY salary DESC
LIMIT 10;


3. Can LIMIT be used with WHERE?

Yes.

SELECT *
FROM employees
WHERE department = 'Finance'
LIMIT 5;


4. Why is ORDER BY important when using LIMIT?

Because without sorting, the returned rows are not necessarily the highest, lowest, newest, or oldest records you want.

5. What is OFFSET used for?

OFFSET skips a specified number of rows before returning the requested rows, commonly for pagination.

🎯 Double Tap ❤️ For More
  • ❤ 1
More from @datasciencefun
  1. Oct 7, 2026🚀 Data Science Roadmap 2026 📍 Phase 3: SQL for Data Science 📖 Topic 4 — LIMIT LIMIT is…
  2. Oct 7, 2026🚀𝗣𝗮𝘆 𝗔𝗳𝘁𝗲𝗿 𝗣𝗹𝗮𝗰𝗲𝗺𝗲𝗻𝘁 𝗧𝗿𝗮𝗶𝗻𝗶𝗻𝗴 | 𝗕𝗲𝗰𝗼𝗺𝗲 𝗮 𝗙𝘂𝗹𝗹𝘀𝘁𝗮𝗰…
  3. Oct 7, 2026𝗠𝗮𝘀𝘁𝗲𝗿 𝗣𝗼𝘄𝗲𝗿 𝗕𝗜 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘! 🔥 Learn Power BI through these FREE learnin…
  4. Oct 2, 2026Data Visualisation tips for beginners
  5. Sep 29, 2026𝗙𝗥𝗘𝗘 𝗥𝗲𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝗧𝗼 𝗟𝗲𝗮𝗿𝗻 𝗔𝗜 𝗶𝗻 𝟮𝟬𝟮𝟲🚀 ​ Explore 6 free resource…
  6. Sep 28, 2026🔹 Real-World Data Science Example Suppose you are analyzing sales data. You want to ident…
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 →