ITeye博客

多行数据合成一行

Acea · 2009-01-14 20:31 · Markdown

SELECT DISTINCT customer_order_no, customer_item_no, customer_name_full OVER (PARTITION BY customer_order_no, customer_item_no) AS customer_name FROM (SELECT customer_order_no, customer_item_no, SYS_CONNECT_BY_PATH (customer_name, ',') customer_name_full FROM ( SELECT customer_order_no, customer_item_no, customer_name, LAG(customer_name, 1, '') OVER (PARTITION BY customer_order_no, customer_item_no ORDER BY customer_name) customer_name_1 FROM ( SELECT t.customer_order_no, t.customer_item_no,t.customer_name FROM tourism_hotel_order_customer t where t.customer_order_no = '20081230R007' and t.customer_item_no = '01' )) CONNECT BY PRIOR customer_name = customer_name_1 ORDER BY customer_order_no, customer_item_no)

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。