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

Leetcode Problem 1082. Sales Analysis I

1082. Sales Analysis I

Leetcode Solutions

Max Sales Filtering with Aggregation

  1. Group the sales table by seller_id and calculate the sum of price for each group to get the total sales per seller.
  2. Find the maximum total sales value from the aggregated results.
  3. Filter the aggregated results to get the seller(s) whose total sales match the maximum sales value.
  4. Select only the seller_id column for the final output, as this is the required information.
erDiagram
    Product {
        int product_id PK
        varchar product_name
        int unit_price
    }
    Sales {
        int seller_id
        int product_id FK >- Product.product_id
        int buyer_id
        date sale_date
        int quantity
        int price
    }

Joining Tables and Using Window Functions

Ask Question

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

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...