Top SQL & Python Interview Questions for Freshers (With Code Solutions)

Whether you are interviewing for a Software Development Engineer (SDE), Data Analyst, or Associate Technical Support role, SQL and Python remain the two most tested skills in online assessments and live technical rounds. Below are the high-frequency concepts and exact query patterns you should master before your next interview.

Part 1: Essential SQL Query Patterns

1. Find the Second Highest Salary from an Employee Table

Interviewers test whether you can handle duplicate salaries and null cases cleanly using subqueries or window functions.

SELECT MAX(salary) AS SecondHighestSalary
FROM Employees
WHERE salary < (SELECT MAX(salary) FROM Employees);

2. Difference Between WHERE and HAVING Clauses

WHERE filters individual rows before grouping occurs and cannot use aggregate functions (like SUM or COUNT). HAVING filters grouped records after the GROUP BY aggregation is applied.

3. Identify Duplicate Records in a Table

SELECT email, COUNT(*) AS occurrence
FROM Users
GROUP BY email
HAVING COUNT(*) > 1;

Part 2: High-Frequency Python Coding Concepts

4. Lists vs. Tuples: When to Use Each?

Lists are mutable (can be modified after creation) and use square brackets []. Tuples are immutable, faster to iterate over, and can be used as dictionary keys because they are hashable.

5. Check for Anagrams in O(N) Time Complexity

Avoid sorting (which takes O(N log N)); use a frequency dictionary or collections.Counter instead:

from collections import Counter

def is_anagram(str1: str, str2: str) -> bool:
    return Counter(str1.lower()) == Counter(str2.lower())

Highlight These Skills on Your Resume

Make sure keywords like SQL Joins, Window Functions, Python, Data Structures, and REST APIs appear in your resume's skills and project sections. Test your keyword score now with our Free ATS Resume Checker.

← Back to Guidance Hub Next: First Tech Offer Guide →