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