Hard-level sql questions from real data engineering interviews.
These hard sql questions are selected from real interviews at top companies. Each question includes a detailed expert answer and pro tip to help you nail your interview.
What is a Common Table Expression (CTE), and when would you use it?
What is the difference between a primary key and a unique key?
Explain Fact and Dimension Tables with examples.
Joins and window functions - INNER, LEFT, RIGHT, FULL OUTER, ROW_NUMBER(), RANK(), DENSE_RANK()
Difference Between Internal and External Tables in BigQuery
How do you optimize a long-running SQL query?
Cloud Architecture - explain
Consolidate hotel reviews and create a dashboard. Design a data model for the reviews.
Create Spark Session, read CSV, join, and write as table. Provide example code.
Data Warehouse Design from scratch
Describe a challenging project where you optimized a complex ETL process.
Describe a recent project where you used AWS services extensively. What was your role, and what challenges did you face?
Describe a scenario where you used Databricks for real-time data processing.
Describe a situation where you had to redesign a data model to meet changing business needs
Describe how metadata is stored and accessed for internal tables in a relational database.
Design a Custom API that can query a backend server and return customer data such as the number of orders placed by a user based on their user ID
Design a daily ETL pipeline to ingest API data into BigQuery.
Design a financial database system focusing on database models, schema design, partition keys, and query optimization techniques.
Design a relational data model for a sales database, incorporating normalization techniques
Design a structure (data model) that allows efficient querying of movies based on multiple search criteria (title, genre, actor, director).
Design the data model for an ETL pipeline that ingests data from a database and loads it into Snowflake
Designing backend architecture for SQL Warehouse?
Designing scalable data models - explain approach
Difference Between Truncate/Delete and Union/Union All – Performance and Usage
Discuss a project where you balanced business goals with technical constraints.
Discuss a project where you significantly impacted performance or cost optimization.
Discuss a project where you significantly improved the performance of a data pipeline.
Does BigQuery support indexes? If not, why?
Explain BigQuery Architecture.
Explain Native vs. External Tables.
Articulate the architectural decisions, scalability trade-offs, and cost implications of designing an AWS data platform. How would you justify glue vs. EMR, Redshift vs. Athena, and when would each choice become cost-prohibitive at scale?
Explain the architectural rationale for using LeftAntiJoin vs. NOT IN vs. NOT EXISTS in a distributed context. When does LeftAntiJoin become a performance or scalability bottleneck, and how do broadcast vs. shuffle joins affect cost?
Explain the architectural trade-offs when optimizing a query on 100M+ rows: indexing vs. partitioning vs. materialized views. When does each approach become cost-prohibitive or operationally burdensome, and how do you quantify impact?
Explain bloom filters in Spark: how they reduce I/O and when they introduce false positives that hurt performance. What are the scalability and cost implications of enabling dynamic partition pruning and bloom filter pushdown at petabyte scale?
Design a star schema for retail analytics (e.g., Adidas). Explain the dimensional modeling choices, SCD strategy, and how you would scale this schema for global multi-currency, multi-region deployments. What are the refresh and storage cost implications?
Explain peer code review and team lead review.
Explain the Medallion Architecture (Bronze, Silver, Gold).
Explain the differences between OLTP and OLAP databases and their relevance in Adidas's operations.
Explain the purpose of windowing and triggering in streaming data pipelines.
Explain the use of Amazon Athena for serverless querying.
Features of NoSQL Databases
Given a CSV file with raw customer transactions, design an ETL pipeline that cleans data, aggregates total sales by region and product, and loads into target table
How can you automate data insertion into BigQuery using Python?
How did you manage a situation where you lacked knowledge for a task?
How do you design a scalable and fault-tolerant data warehouse on a cloud platform?
How do you handle situations where you disagree with feedback from others?
How does AQE optimize join operations dynamically?
How does it differ from static partition pruning?
How to Use Dataflow with BigQuery
How would you design a data model for an e-commerce platform?
How would you optimize a SQL query for better performance when working with large datasets?
In Python, process a large CSV in chunks and remove duplicate records based on email and timestamp.
Indexing - True/False question on indexes and query optimization
Kafka Basics - architecture, topics, partitions, producers, consumers, Zookeeper
Motivation for Joining Snowflake?
NoSQL Database - Cassandra fundamentals
Optimization Techniques Beyond Repartitioning and Caching
Optimization techniques - partitioning, caching, broadcast joins, bucketing
Optimization: Performance tuning strategies and temporal tables
Query Optimization Strategies
Download the complete interview prep bundle with expert answers. Study offline, on your commute, anywhere.