bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 1098. Unpopular Books

1098. Unpopular Books

Leetcode Solutions

Filtering and Aggregating Sales Data

  1. Calculate the date one month before the current date (2019-05-23).
  2. Select all books that have been available before this calculated date.
  3. Calculate the date one year before the current date (2018-06-23).
  4. Aggregate the total quantity of books sold from the orders table for each book between the date one year ago and the current date.
  5. Use a LEFT JOIN to combine the books and aggregated sales data.
  6. Filter the combined data to find books with total sales less than 10 copies.
  7. Select the required columns (book_id and name) for the final output.
erDiagram
    Books {
        int book_id PK
        varchar name
        date available_from
    }
    Orders {
        int order_id PK
        int book_id FK
        int quantity
        date dispatch_date
    }

Using Subqueries for Filtering and Aggregation

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...