建立Table CREATE TABLE sales ( department VARCHAR(50), employee VARCHAR(50), sale_date DATE, amount DECIMAL(10, 2) ); INSERT INTO sales VALUES ('部門A', '員工1', '2023-01-01', 100.00), ('部門A', '員工1', '2023-01-02', 150.00), ('部門A', '員工2', '2023-01-01', 200.00), ('部門B', '員工3', '2023-01-01', 50.00), ('部門B', '員工3', '2023-01-02', 75.00), ('部門B', '員工4', '2023-01-01', 300.00); 資料結構: department employee sale_date amount 部門A 員工1 2023/1/1 100 部門A 員工1 2023/1/2 150 部門A 員工2 2023/1/1 200 部門B 員工3 2023/1/1 50 部門B 員工3 2023/1/2 75 部門B 員工4 2023/1/1 300 在分區中計算行號: SELECT department, employee, sale_date, ROW_NUMBER() OVER (PARTITION BY department ORDER BY sale_date) AS row_num FROM sales; 資料結果: department employee sale_date row_num 部門A 員工1 2023/1/1 1 部門A 員工2 2023/1/1 2 部門A 員工1 2023/1/2 3 部門B 員工3 2023/1/1 1 部門B 員工4 202...