SQL Dialects and Built-in Functions Questions

Portability and idiom differences across SQL engines (PostgreSQL, Redshift, MySQL, SQL Server, and others), plus fluent use of built-in string, date/time, and type-conversion functions. Covers dialect-specific syntax, function availability, and writing queries that behave predictably across platforms. Relevant when candidates move between database ecosystems.

MediumTechnical
97 practiced

You have subscription records per customer with start_date and end_date, and you want to identify customers with gaps greater than 1 day between consecutive subscriptions as well as any overlapping subscriptions. Write a SQL query (using window functions) that finds these gaps and overlaps, and explain how you would test it with sample data including edge cases.

EasyTechnical
89 practiced

Given a table orders(order_id int, user_id int, order_ts timestamptz, amount numeric) in PostgreSQL, write a query to return all orders from the last 7 days inclusive of today. Explain your choice between using CURRENT_DATE vs now()::date and how you would change the query if order_ts is stored without timezone or in a different timezone.

HardSystem Design
89 practiced

Design an incremental materialized view or summary table that is refreshed daily to support queries for the last 365 days aggregated by day. Describe how to implement incremental refresh (what partitions to recompute), how to handle late-arriving data that affects historical partitions, and how to keep the refresh time low while ensuring correctness.

HardTechnical
96 practiced

Given event logs with columns (user_id, event_ts string, user_tz string) write a Python/pandas algorithm to assign session IDs per user where a new session starts after 30 minutes of inactivity. Handle cross-midnight sessions and DST shifts, and discuss how to make the implementation scalable for tens of millions of events (e.g., chunking, using Dask, or streaming).

HardTechnical
104 practiced

Write an audit SQL query to find transactions whose timestamps are in the future (transaction_ts > now()) across multiple source systems. Explain how clock skew and timezone misinterpretation can cause this, and propose automated detection rules and remediation steps (e.g., quarantining, adjusting timestamps, notifying source owners).

Unlock Full Question Bank

Get access to all SQL Dialects and Built-in Functions interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.