Home > database >  Help: oracle PLSQL aspect, according to a field with the rest of the same field of SQL requirements
Help: oracle PLSQL aspect, according to a field with the rest of the same field of SQL requirements

Time:01-28

SQL is a demand of oracle data as follows, don't know how to complete the SQL is better, consult!
The table name: test

Table data following screenshots:
FA_ITEM SON_ITEM NUM DISTOR
10 0302 0709 a000 y000 2 R14, R15
1 0302 0709 a000 y000 3 R1, R2, R3
3 0302 0709 a001 y000 R7 and R8, and R9, R10, R11
2 0302 0709 a001 y000 3 R4, R5, R6
6 0302 0709 a002 y000 1 R12
4 0302 0709 a002 y000 2 A1, A2
5 0302 0709 a002 y000 4 A3, A4, A6, A5
9 0302 y000 0709 a003 3 B12, bl3 B14
7 0302 y000 0709 a003 7 B1, B2, B3, B4, B5, B6 and B7
8 0302 0709 a004 y000 4 B8, B9, B10, bl1


Demand for SQL:
According to son_item fields, such as have the same value, then the content of the combination of num column number and distor,
The results are as follows:
FA_ITEM SON_ITEM NUM DISTOR
1 0302 0709 a000 y000 R14, R15, R1, R2, R3
2 0302 0709 a001 y000 8 R4, R5, R6 and R7 and R8, and R9, R10, R11
3 0302 0709 a002 y000 7 R12, A1, A2, A3, A4, A6, A5
4 0302 y000 0709 a003 10 B12, bl3, B14, B1, B2, B3, B4, B5, B6 and B7
5 0302 0709 a004 y000 4 B8, B9, B10, bl1
  • Related