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
93 practiced

Implement a 7-day rolling average of 'amount' per user using window frames. First, write the BigQuery/Postgres query using RANGE BETWEEN INTERVAL '6 days' PRECEDING AND CURRENT ROW. Then explain how you would adapt this for SQL Server if RANGE doesn't accept an INTERVAL on datetime types; provide an alternative approach for SQL Server.

EasyTechnical
88 practiced

Get the first day of the month for a date column 'order_date' in PostgreSQL, BigQuery, Snowflake, and SQL Server. Show the SQL expression for each dialect and explain why DATE_TRUNC exists in some systems while SQL Server requires a date arithmetic workaround.

HardTechnical
85 practiced

During the fall DST transition (clocks go back), some timestamps are ambiguous (e.g., '2023-11-05 01:30' occurs twice in 'America/New_York'). As a BI engineer, describe how you'd detect, store, and disambiguate such events so reporting doesn't double-count or misorder events. Include storage recommendations and any data model changes.

EasyTechnical
101 practiced

Explain the difference between PostgreSQL types timestamp with time zone (timestamptz) and timestamp without time zone. For a BI team, what is the recommended type to store event times and why? Include examples of common pitfalls.

EasyTechnical
99 practiced

You have an events table with columns: (event_id INT, event_ts TIMESTAMP WITH TIME ZONE). Write a PostgreSQL query that returns event_id plus extracted fields: event_date (date), year, month, day, hour, and ISO week number for each timestamp. Show how EXTRACT, DATE_PART and DATE_TRUNC differ and when you'd use each for BI aggregations.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.