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

You have a denormalized table events(user_id, event_type, properties jsonb, occurred_at). A business asks for monthly revenue by product category, but product is nested inside properties->'product_id'. Write a SQL query showing how you'd extract product_id from JSON and join to products(product_id, category) to compute monthly revenue. Assume PostgreSQL.

HardSystem Design
105 practiced

You must build a dashboard (Tableau or Power BI) that shows 7, 14, and 30-day rolling retention rates, connected live to a data warehouse with large tables. Explain architectural choices to keep dashboard performance acceptable: extracts vs live, pre-aggregations, materialized views, incremental refresh, and how to design the visual calculations (LOD vs precomputed metrics).

MediumTechnical
79 practiced

Design an upsert (merge) operation to update a dimension table customer_dim from a staging table staging_customers. Schema:

customer_dim(customer_id PK, name, email, last_updated)
staging_customers(customer_id, name, email, source_updated_at)

Provide SQL for PostgreSQL (INSERT ... ON CONFLICT DO UPDATE) or SQL Server MERGE and explain how to make the operation idempotent and safe for concurrent runs.

HardTechnical
97 practiced

Write a SQL query (for BigQuery or Postgres) that computes period-over-period growth comparing the last N days (e.g., 28 days ending yesterday) to the previous N days. Ensure the query is correct when data has late-arriving records (i.e., events ingested after their event date) and describe how you would use watermarks or ingestion timestamps to make the comparison reliable.

EasyTechnical
93 practiced

In Power BI you have a sales table with sale_date (date) and amount. Write or describe a DAX measure to compute Year-To-Date (YTD) sales that respects the model's date table and works correctly when the report's filter context changes. Explain why a measure is preferred over a calculated column for YTD and what date table properties must be set.

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.