oracle資料的sql有個需求如下,不知道sql怎么完成比較好,請教!
table名:test
表資料如下截圖:
FA_ITEM SON_ITEM NUM DISTOR
10 0302Y000 0709A000 2 R14,R15
1 0302Y000 0709A000 3 R1,R2,R3
3 0302Y000 0709A001 5 R7,R8,R9,R10,R11
2 0302Y000 0709A001 3 R4,R5,R6
6 0302Y000 0709A002 1 R12
4 0302Y000 0709A002 2 A1,A2
5 0302Y000 0709A002 4 A3,A4,A6,A5
9 0302Y000 0709A003 3 B12,B13,B14
7 0302Y000 0709A003 7 B1,B2,B3,B4,B5,B6,B7
8 0302Y000 0709A004 4 B8,B9,B10,B11
對sql的需求:
根據son_item欄位,如有有相同的值,則合并num列數量和distor的內容。
結果如下:
FA_ITEM SON_ITEM NUM DISTOR
1 0302Y000 0709A000 5 R14,R15,R1,R2,R3
2 0302Y000 0709A001 8 R4,R5,R6,R7,R8,R9,R10,R11
3 0302Y000 0709A002 7 R12,A1,A2,A3,A4,A6,A5
4 0302Y000 0709A003 10 B12,B13,B14,B1,B2,B3,B4,B5,B6,B7
5 0302Y000 0709A004 4 B8,B9,B10,B11
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/253187.html
標籤:開發
上一篇:學會熟練使用MySQL索引,快速檢索資料庫,大大提升作業效率
下一篇:《MySQL必知必會》匯入資料庫時出現ERROR 1146 (42S02): Table 'populate.列名' doesn't exist錯誤
