Post content
✅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! ❤️