# Sales Analysis I LeetCode Solution

This Leetcode problem Sales Analysis I LeetCode Solution is done in SQL.

# List of all LeetCode Solution

## Problem Statement

product_id is the primary key (column with unique values) of this table. Each row of this table indicates the name and the price of each product.

This table can have duplicate rows. product_id is a foreign key (reference column) to the Product table. Each row of this table contains some information about one sale.

Write an SQL query that reports the best seller by total sales price, If there is a tie, report them all.

The result format is in the following example.

``<strong>Output:</strong>`Code language: HTML, XML (xml)`
``````<strong>Explanation:</strong>
Both sellers with id 1 and 3 sold products with the most total price of 2800.```Code language: HTML, XML (xml)```

## Sales Analysis I LeetCode Solution MySQL

``````select
seller_id
from
Sales
group by
seller_id
having
sum(price) >= (
select
sum(price) as total_price
from
Sales
group by
seller_id
order by
total_price desc
limit
1
);```Code language: SQL (Structured Query Language) (sql)```
Scroll to Top