SQL is the one skill every data, analyst and backend interview checks. These ten questions come up constantly for freshers. Every query below uses one small sample schema (students, courses, enrollments) so you can run it yourself. (Full answers and FAQs: SQL Interview Questions for Freshers .)
Basics
1. DELETE vs TRUNCATE vs DROP? DELETE removes chosen rows and accepts a WHERE clause. TRUNCATE quickly clears all rows but keeps the table. DROP removes the table itself.
2. Primary key vs foreign key? A primary key uniquely identifies each row. A foreign key in another table points to it and links the two tables.
3. WHERE vs HAVING? WHERE filters rows before grouping. HAVING filters groups after GROUP BY:
SELECT course_id , COUNT (*) AS enrolled FROM enrollments GROUP BY course_id HAVING COUNT(*) > 20 ;
Enter fullscreen mode
Exit fullscreen mode
Joins
4. Types of joins? INNER returns only matches. LEFT keeps every left-table row and fills gaps with NULL. RIGHT mirrors LEFT.…