Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL: 100th Element Query

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is SQL: 100th Element Query. Start with the requirements and the two tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Akamai engineers need to validate a generated sequence of service positions against metadata for Akamai delivery products. Write a PostgreSQL query that generates the first 120 elements, joins each element to its corresponding product, and returns only the 100th element.

Requirements

  1. Generate integer positions from 1 through 120 using PostgreSQL generate_series.
  2. Map positions cyclically to service IDs 1 through 4 and join them to akamai_products.
  3. Return the 100th position, its service ID, product name, and product family.
  4. Preserve the requested position explicitly with an ORDER BY clause.

Schema

akamai_products
ColumnTypeDescription
service_idPKINTEGERUnique Akamai product service identifier
product_nameVARCHAR(100)Akamai product name
product_familyVARCHAR(100)Product family
region_codeVARCHAR(10)Primary deployment region
edge_service_registry
ColumnTypeDescription
service_idPKINTEGERRegistered service identifier
service_statusVARCHAR(20)Current service status
owner_teamVARCHAR(100)Responsible Akamai team
Tablesakamai_productsedge_service_registry
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results