# Top 50 SQL Interview Questions Asked by FAANG Companies in 2025
## Introduction
Landing a job at FAANG companies (Facebook/Meta, Amazon, Apple, Netflix, Google) requires mastering SQL interview questions that test both your technical knowledge and problem-solving abilities. This comprehensive guide covers the most frequently asked SQL questions in 2025 interviews.
## Most Common SQL Interview Question Categories
### 1. Basic SQL Queries (Asked by 95% of companies)
**Question 1: Write a query to find the second highest salary from an employees table.**
```sql
-- Method 1: Using LIMIT and OFFSET
SELECT salary
FROM employees
ORDER BY salary DESC
LIMIT 1 OFFSET 1;
-- Method 2: Using subquery
SELECT MAX(salary)
FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);
```
**Question 2: Find duplicate records in a table.**
```sql
SELECT email, COUNT(*)
FROM users
GROUP BY email
HAVING COUNT(*) > 1;
```
### 2. JOIN Operations (Asked by 90% of companies)
**Question 3: Write a query to find employees who don't have a manager.**
```sql
SELECT e1.name
FROM employees e1
LEFT JOIN employees e2 ON e1.manager_id = e2.id
WHERE e2.id IS NULL;
```
**Question 4: Find customers who have never placed an order.**
```sql
SELECT c.customer_name
FROM customers c
LEFT JOIN orders o ON c.customer_id = o.customer_id
WHERE o.customer_id IS NULL;
```
### 3. Window Functions (Asked by 85% of FAANG companies)
**Question 5: Rank employees by salary within each department.**
```sql
SELECT
name,
department,
salary,
RANK() OVER (PARTITION BY department ORDER BY salary DESC) as salary_rank
FROM employees;
```
**Question 6: Calculate running total of sales.**
```sql
SELECT
date,
sales,
SUM(sales) OVER (ORDER BY date) as running_total
FROM daily_sales;
```
### 4. Subqueries and CTEs (Asked by 80% of companies)
**Question 7: Find departments with more than 5 employees.**
```sql
WITH dept_counts AS (
SELECT department_id, COUNT(*) as emp_count
FROM employees
GROUP BY department_id
)
SELECT d.department_name
FROM departments d
JOIN dept_counts dc ON d.id = dc.department_id
WHERE dc.emp_count > 5;
```
### 5. Date and Time Functions (Asked by 75% of companies)
**Question 8: Find users who signed up in the last 30 days.**
```sql
SELECT user_id, signup_date
FROM users
WHERE signup_date >= CURRENT_DATE - INTERVAL 30 DAY;
```
## Advanced SQL Questions for Senior Positions
### Complex Analytical Queries
**Question 9: Calculate month-over-month growth rate.**
```sql
WITH monthly_sales AS (
SELECT
DATE_TRUNC('month', order_date) as month,
SUM(amount) as total_sales
FROM orders
GROUP BY DATE_TRUNC('month', order_date)
)
SELECT
month,
total_sales,
LAG(total_sales) OVER (ORDER BY month) as prev_month_sales,
ROUND(
(total_sales - LAG(total_sales) OVER (ORDER BY month)) * 100.0 /
LAG(total_sales) OVER (ORDER BY month), 2
) as growth_rate_percent
FROM monthly_sales;
```
**Question 10: Find the top 3 products by revenue in each category.**
```sql
WITH product_revenue AS (
SELECT
p.category,
p.product_name,
SUM(oi.quantity * oi.price) as revenue,
ROW_NUMBER() OVER (PARTITION BY p.category ORDER BY SUM(oi.quantity * oi.price) DESC) as rn
FROM products p
JOIN order_items oi ON p.product_id = oi.product_id
GROUP BY p.category, p.product_name
)
SELECT category, product_name, revenue
FROM product_revenue
WHERE rn <= 3;
```
## Company-Specific Question Patterns
### Google SQL Interview Focus Areas
- Complex analytical queries
- Performance optimization
- Data modeling scenarios
- Statistical functions
### Amazon SQL Interview Focus Areas
- E-commerce data analysis
- Customer behavior queries
- Inventory management scenarios
- Time-series analysis
### Meta/Facebook SQL Interview Focus Areas
- Social media analytics
- User engagement metrics
- A/B testing analysis
- Graph-like data queries
### Netflix SQL Interview Focus Areas
- Content recommendation queries
- User viewing patterns
- Streaming analytics
- Cohort analysis
### Apple SQL Interview Focus Areas
- Product analytics
- Sales performance queries
- Supply chain data analysis
- Customer segmentation
## Performance Optimization Questions
**Question 11: How would you optimize a slow query?**
Key strategies:
1. **Indexing**: Create appropriate indexes on frequently queried columns
2. **Query rewriting**: Use EXISTS instead of IN for subqueries
3. **Partitioning**: Partition large tables by date or other logical divisions
4. **Avoiding functions in WHERE clauses**: Use sargable predicates
**Question 12: Explain the difference between clustered and non-clustered indexes.**
- **Clustered Index**: Physically reorders table data, one per table
- **Non-clustered Index**: Creates separate structure pointing to data rows, multiple allowed
## Database Design Questions
**Question 13: Design a schema for a social media platform.**
Key considerations:
- User profiles table
- Posts/content table
- Relationships/friendships table
- Comments and likes tables
- Proper normalization (3NF)
- Indexing strategy for performance
## Tips for FAANG SQL Interviews
### 1. Practice Problem-Solving Approach
- Understand the business context
- Break down complex problems
- Think about edge cases
- Consider performance implications
### 2. Communication Skills
- Explain your thought process
- Discuss trade-offs
- Ask clarifying questions
- Walk through your solution step by step
### 3. Technical Depth
- Know SQL execution order
- Understand indexing strategies
- Be familiar with query optimization
- Know different database systems (MySQL, PostgreSQL, etc.)
### 4. Real-World Application
- Connect queries to business metrics
- Discuss scalability concerns
- Consider data quality issues
- Think about maintenance and monitoring
## Common Mistakes to Avoid
1. **Not handling NULL values properly**
2. **Forgetting about data types and implicit conversions**
3. **Not considering query performance**
4. **Overlooking edge cases**
5. **Poor naming conventions**
6. **Not using appropriate JOINs**
## Conclusion
Mastering these SQL interview questions requires consistent practice and understanding of both syntax and business applications. Focus on:
- **Core SQL concepts**: JOINs, subqueries, window functions
- **Performance optimization**: Indexing, query tuning
- **Real-world scenarios**: Business metrics, data analysis
- **Communication**: Explaining your approach clearly
## Next Steps
1. **Practice these questions** using our interactive SQL interview simulator
2. **Time yourself** to simulate real interview conditions
3. **Focus on weak areas** identified through practice
4. **Study company-specific patterns** based on your target companies
Ready to practice? [Start your SQL interview preparation now →](/interview)