Comprehensive SQL Python Interview Guide
Comprehensive SQL Python Interview Guide
Table of Contents
1. Basic SELECT
Question: Write a SQL query to get all records from the 'employees' table.
2. WHERE Clause
Question: Get all customers from 'customers' table where country is 'USA'.
3. ORDER BY
5. HAVING
6. INNER JOIN
7. LEFT JOIN
8. Subquery
SELECT * FROM products WHERE product_id NOT IN (SELECT product_id FROM orders);
9. UNION
SELECT order_id, amount, CASE WHEN amount > 1000 THEN 'High' ELSE 'Low' END AS
order_priority FROM orders;
1. List Comprehension
2. Dictionary Comprehension
3. Lambda Function
add_ten = lambda x: x + 10
Comprehensive Guide: SQL & Python Interview Preparation
4. Filter Function
5. Map Function
6. Reduce Function
7. Try-Except
try:
x = 1 / 0
except ZeroDivisionError:
print('Cannot divide by zero')
class Person:
def __init__(self, name):
self.name = name
def __str__(self):
return f'Person: {self.name}'
9. Read File
10. Decorator
def log(func):
def wrapper(*args, **kwargs):
print(f'Calling {func.__name__}')
return func(*args, **kwargs)
return wrapper