```sql SELECT * FROM ( SELECT ROW_NUMBER() OVER (PARTITION BY user_no ORDER BY amount DESC) AS row_num, order_id, user_no, amount, create_date FROM order_tb ) AS t WHERE t.row_num <= 3; ```
```sql SELECT t.* FROM ( SELECT RANK() OVER w AS Rank_num, PERCENT_RANK() OVER w AS percent, order_id, user_no, amount FROM order_tb WINDOW w AS (PARTITION BY user_no ORDER BY amount DESC) ) AS t; ```
```sql SELECT order_id, user_no, amount, create_date, last_date, DATEDIFF(create_date, last_date) AS diff FROM ( SELECT order_id, user_no, amount, create_date, LAG(create_date, 1) OVER w AS last_date FROM order_tb WINDOW w AS (PARTITION BY user_no ORDER BY create_date) ) AS t; ```
```sql SELECT * FROM ( SELECT order_id, user_no, amount, create_date, FIRST_VALUE(amount) OVER w AS first_amount, LAST_VALUE(amount) OVER w AS last_amount FROM order_tb WINDOW w AS (PARTITION BY user_no ORDER BY create_date) ) AS t; ```
```sql SELECT * FROM ( SELECT NTILE(3) OVER w AS nf, order_id, user_no, amount, create_date FROM order_tb WINDOW w AS (PARTITION BY user_no ORDER BY amount DESC) ) AS t; ```
```sql SELECT * FROM ( SELECT order_id, user_no, amount, create_date, SUM(amount) OVER w AS sum1, AVG(amount) OVER w AS avg1, MAX(amount) OVER w AS max1, MIN(amount) OVER w AS min1, COUNT(amount) OVER w AS count1 FROM order_tb WINDOW w AS (PARTITION BY user_no ORDER BY order_id) ) AS t; ```