Leetcode Problem 1831. Maximum Transaction Each Day

1831. Maximum Transaction Each Day

Leetcode Solutions

Using Window Function DENSE_RANK

  • Use the DENSE_RANK() window function to assign a rank to each transaction based on the amount within each day.
  • Partition the data by the date of the day and order by the amount in descending order within each partition.
  • Filter the ranked transactions to only include those with a rank of 1, which are the transactions with the maximum amount for their respective day.
  • Order the final result by transaction_id in ascending order.
erDiagram
    Transactions {
        int transaction_id
        datetime day
        int amount
    }

Using Self-Join to Find Maximum Transactions

Ask Question

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

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...