InterviewStack.io LogoInterviewStack.io

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

Given a Postgres table events(id INT, payload JSONB) where payload contains an array of items with keys item_id and price, write SQL to flatten JSON, extract item_id and price, and compute total revenue per item_id. Consider missing keys and types.

HardTechnical
85 practiced

Different SQL dialects have subtle differences in join behavior and syntax (for example, USING vs ON, IS NOT DISTINCT FROM in Postgres, lateral joins in Postgres vs CROSS APPLY in SQL Server). Pick 2 differences between popular dialects (Postgres, MySQL, BigQuery, Snowflake) affecting joins and show how you would write a portable query or document required adjustments for each target database.

MediumTechnical
71 practiced

Orders have timestamps stored in UTC in orders(order_id, order_date TIMESTAMPTZ, total_amount). In PostgreSQL, write a query that returns monthly revenue in the America/Los_Angeles timezone for a specific year. Make sure months align to local timezone months.

MediumTechnical
79 practiced

Write an idempotent upsert for table model_predictions(user_id PK, prediction FLOAT, updated_at TIMESTAMP) in Postgres and show the ANSI SQL MERGE equivalent if available. Discuss performance implications of frequent upserts at scale and patterns like staging tables and batch merges.

MediumTechnical
87 practiced

You have an events table with a JSON column 'attributes' that contains an array of tag objects. Write a SQL query (in a dialect that supports JSON functions, e.g., Postgres or BigQuery) that unnests the JSON array and joins tags to a tags_master table to get tag metadata, ensuring you do not create unwanted duplicates when events have repeated tag entries.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.