Top 50 SQL Interview Questions
The most frequently asked questions on this topic across all roles and companies, ranked by real interview frequency. Updated daily.
Find the second highest distinct salary from a single table using basic PostgreSQL ordering and limiting.
eClinicalWorksNNeenOpal Canada
InformaticaFind the second highest salary in each department without using aggregate functions.
Credit Genie
Devoteam
Cisco Restaurant + BarCompute daily active users and a 7-day rolling average using a CTE, distinct counts, and window functions.
Meta
Spotify
Meta ITCalculate a three-day moving average of active-client revenue using aggregation and SQL window functions.
Sign up to see every question
Create a free account to unlock this list and practice real interview questions.
Rewrite a slow PostgreSQL loan payment query to reduce scanned rows while preserving the required aggregated results.
AmeripriseEEltro Cyberchrome Private
EnergyHubCalculate the monthly spending trends for customers using window functions and joins.
The Home Depot
Aviso
Hewlett Packard EnterpriseUse GROUP BY and SUM to rank the top 10 customers by total revenue from a single sales table.
Housecall Pro
Equifax
XYZReplace missing sales fields with defined defaults and return a consistently ordered dataset.
University of Minnesota
The Home Depot
Nationwide