【发布时间】:2020-10-05 08:49:12
【问题描述】:
有这样一张桌子
+--------+------------+
| orderID | productID |
+--------+------------+
| 100 | 10 |
| 100 | 11 |
| 101 | 10 |
| 101 | 11 |
| 101 | 12 |
+--------+------------+
我需要添加第三列,即产品当前位置的计数器。 喜欢:
+--------+------------+--------------+
| orderID | productID | currentIndex |
+--------+------------+--------------+
| 100 | 10 | 1 |
| 100 | 11 | 2 |
| 101 | 10 | 1 |
| 101 | 11 | 2 |
| 101 | 12 | 3 |
+--------+------------+--------------+
可以帮帮我吗?
我现在有这个查询:
SELECT orderID, productID
FROM orders;
【问题讨论】:
标签: mysql sql select window-functions