Skip to content
Quantoros

Return pairs of CONSECUTIVE calendar dates (day1, day2) where the total order amount exceeded 500 on BOTH days. Table…

SQLLevel: AdvancedGaps, islands and streaks

Return pairs of CONSECUTIVE calendar dates (day1, day2) where the total order amount exceeded 500 on BOTH days.

Table definitions (from the source exercise):

CREATE TABLE orders(order_id INTEGER PRIMARY KEY, customer_id INTEGER, order_date TEXT, amount REAL, rep_id INTEGER, discount REAL);
Hints
  • Define one output row and the source-table keys.
  • Check duplicates, NULLs and the order of filtering and aggregation.

Answer

This answer is part of mentoring

Advanced questions come with a full breakdown and a mock interview with a working quant researcher. The first call is free.

Source and licence: SQL Practice Lab — Ebrahim Sharifi · MIT

Related questions