需要SQL查询来比较重复值并打印相应的列名称

时间:2017-07-03 17:36:35

标签: sql oracle oracle11g

HI专家,需要您帮助我解决oracle中的以下要求。

  1. 我有列的列表,根据型号列过滤器我需要知道其他列是否有任何重复值,如果是,那么它应该将注释列显示为列名+重复值(例如:具有重复值的Category_description)

  2. 如果任何列为空白,则应打印列名称为空(例如:父类别ID为空白值)。

  3. 数据是:

    M_No    CAT_DESC              CAT_ID    P_CAT_ID    Comments
    1       computer hardware     10        90  
    1       monitors              11        10  
    1       printers              12        10  
    1       harddisks             13        10        CAT_DESC duplicate
    1       memory components     14        10  
    1       harddisks             15        10        CAT_DESC duplicate
    1       keyboards, mouses     16        10  
    1       other peripherals     17        10  
    1       harddisks             19        10        CAT_DESC duplicate
    2       office fur supplies   30        90  
    2       capitalizable assets  31        30  
    2       office daily use      32        30  
    2       manuals, other books  33        30      CAT_DESC, CAT_ID duplicate
    2       manuals, other books  33        30      CAT_DESC, CAT_ID duplicate
    3       computer hardware     90                 P_CAT_ID is blank value
    4       computer software     20        90  
    4       spreadsheet software  21        20  
    4       processing software   22        20  
    4                             23                CAT_DESC, P_CAT_ID is blank 
    4      operating systems      24        20  
    4      software development   25        20  
    4      miscellaneous software 29        20  
    

0 个答案:

没有答案