Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一张带有 customer_id 和 order_id 的表,我想根据 customer_id 对其进行排序。这是如何在 Vertica SQL 中完成的?
c_id o_id 1 1 2 3 1 4 2 5 3 6 3 7
我想要:
c_id o_id 序列 1 1 1 1 4 2 2 3 1 2 5 2 3 6 1 3 7 2
据我所知,Vertica 支持(标准)窗口函数,所以以下应该可以工作:
select c_id, o_id, row_number() over (partition by c_id order by o_id) as seq from the_table order by c_id, o_id