Skip to content
SQLSimplified
FreshersQuestion 19 of 50

Skipping Records with OFFSET

Problem

A streaming website wants to display movies in groups of 3. Skip the first 3 oldest movies and retrieve the next 3 oldest movies. Order the movies by release_year in ascending order.

Database Schema

Table: movies

  • id (INT): Unique identifier for the movie.
  • title (VARCHAR): Title of the movie.
  • genre (VARCHAR): Genre of the movie.
  • release_year (INT): The year the movie was released.
  • director (VARCHAR): Director of the movie.
  • budget_millions (INT): Movie budget in millions of dollars.

Table: actors

  • id (INT): Unique identifier for the actor.
  • name (VARCHAR): Name of the actor.
  • birth_year (INT): Birth year of the actor.
  • primary_movie_id (INT): Foreign key referencing the movie they are best known for.

Table: ratings

  • id (INT): Unique identifier for the rating.
  • movie_id (INT): Foreign key referencing the movie.
  • source (VARCHAR): The source of the rating (e.g., Critics, Audience).
  • score (DECIMAL): Numeric score.

Try It

Loading playground environment...

Hint

Solution