TGViewer
SQL Programming Resources SQL Programming Resources @sqlanalyst · 76.7K subscribers
Post #2169 5.91K
✅ Top 10 SQL Interview Questions

1️⃣ What is SQL and its types? 
SQL (Structured Query Language) is used to manage and manipulate databases. 
Types: DDL, DML, DCL, TCL 
Example: CREATE, SELECT, GRANT, COMMIT

2️⃣ Explain SQL constraints. 
Constraints ensure data integrity:
⦁ PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, CHECK

3️⃣ What is normalization? 
It's organizing data to reduce redundancy and improve integrity (1NF, 2NF, 3NF…).

4️⃣ Explain different types of JOINs with example.
⦁ INNER JOIN: Returns matching rows
⦁ LEFT JOIN: All from left + matching right rows
⦁ RIGHT JOIN: All from right + matching left rows
⦁ FULL JOIN: All rows from both tables

5️⃣ What is a subquery? Give example. 
A query inside another query:
SELECT name FROM employees
WHERE department_id = (SELECT id FROM departments WHERE name='Sales');


6️⃣ How to optimize slow queries? 
Use indexes, avoid SELECT *, use joins wisely, reduce nested queries.

7️⃣ What are aggregate functions? List examples. 
Functions that perform a calculation on a set of values: 
SUM(), COUNT(), AVG(), MIN(), MAX()

8️⃣ Explain SQL injection and prevention. 
A security vulnerability to manipulate queries. Prevent via parameterized queries, input validation.

9️⃣ How to find Nth highest salary without TOP/LIMIT?
SELECT DISTINCT salary FROM employees e1
WHERE N-1 = (SELECT COUNT(DISTINCT salary) FROM employees e2 WHERE e2.salary > e1.salary);


🔟 What is a stored procedure? 
A precompiled SQL program that can be executed to perform operations repeatedly.

🔥 React for more! ❤️
  • ❤ 8
More from @sqlanalyst
  1. Oct 13, 2026SQL Interview Series — Part 8 📌 Question 8: Find Customers Who Have Never Placed an Order…
  2. Oct 13, 2026𝗧𝗢𝗣 𝗙𝗥𝗘𝗘 𝗖𝗢𝗨𝗥𝗦𝗘𝗦 𝗧𝗢 𝗕𝗢𝗢𝗦𝗧 𝗬𝗢𝗨𝗥 𝗦𝗞𝗜𝗟𝗟𝗦 𝗜𝗡 𝟮𝟬𝟮𝟲! Explor…
  3. Oct 12, 2026SQL Interview Series — Part 6 📌 Question 6: Find the Top 2 Highest-Paid Employees in Each…
  4. Oct 12, 2026🚀 𝗪𝗵𝗶𝗰𝗵 𝗧𝗲𝗰𝗵 𝗦𝗸𝗶𝗹𝗹 𝗪𝗶𝗹𝗹 𝗬𝗼𝘂 𝗠𝗮𝘀𝘁𝗲𝗿 𝗶𝗻 𝟮𝟬𝟮𝟲? Want to buil…
  5. Oct 9, 2026SQL Interview Series — Part 5 📌 Question 5: Find Employees Who Earn More Than Their Manag…
  6. Oct 9, 2026🇮🇳 𝗚𝗢𝗩𝗘𝗥𝗡𝗠𝗘𝗡𝗧 𝗢𝗙 𝗜𝗡𝗗𝗜𝗔 — 𝗔𝗜𝗖𝗧𝗘 𝗜𝗡𝗧𝗘𝗥𝗡𝗦𝗛𝗜𝗣𝗦 𝟮𝟬𝟮𝟲 🚀…
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 →