在Oracle中分组忽略NULL

时间:2015-09-25 16:51:43

标签: oracle

enter image description here

您好 我有上面的数据表,我想将它们组成一行忽略NULL值,对此有任何帮助,非常感谢,

2 个答案:

答案 0 :(得分:0)

你可以尝试这个查询,它会起作用

   select   max(classid),
    classname,
    max(frequency),
    max(notice),
    max(typeofdays),
    max(rnotice),
    max(classpercent)
  from <table_name>
  group by classname;

答案 1 :(得分:0)

使用滞后和分区可以解决我的要求

SELECT FUND_CLASS_ID,

         NVL(SUB_NOTICE_DAYS     , LAG (SUB_NOTICE_DAYS     , 1) OVER (PARTITION BY LFC.ID ORDER BY SUB_NOTICE_DAYS       NULLS LAST)) SUB_NOTICE_DAYS     , 
         NVL(SUB_NOTICE_TYPE_OF_DAYS_ID             , LAG (SUB_NOTICE_TYPE_OF_DAYS_ID             , 1) OVER (PARTITION BY LFC.ID ORDER BY SUB_NOTICE_TYPE_OF_DAYS_ID               NULLS LAST)) SUB_NOTICE_TYPE_OF_DAYS_ID  
     FROM CLASS