配置单元中的多个union语句未给出正确的结果

qlckcl4x  于 2021-06-01  发布在  Hadoop
关注(0)|答案(0)|浏览(156)

我正在尝试在使用多个union和union all语句的配置单元中运行简单的转换。我正在从oracle中提取数据。oracle查询:

SELECT t1.column1,                      
       t2.column2,                      
       t1.column3,                                              
  FROM table1 t1, table2 t2                     
  WHERE t1.column1 = t2.column1 and t1.column2 IN (3, 5, 8, 13) 

UNION ALL                       

  (SELECT t1.column1,                       
          t2.column2,                       
          t1.column3,                                               
    FROM table1 t1, table2 t2                       
    WHERE t1.column1 = t2.column1 and t1.column2 = 4    

   UNION                        

   SELECT t1.column1,                       
          t2.column2,                       
          t1.column3,                                               
     FROM table1 t1, table2 t2                          
     WHERE A.CAL = B.CAL and a.type = 4                         
           and (t1.column1 not like '%ABC%))

配置单元查询:

SELECT t1.column1,                      
       t2.column2,                      
       t1.column3,                                              
  FROM table1 t1, table2 t2                     
  WHERE t1.column1 = t2.column1 and t1.column2 IN (3, 5, 8, 13) 

UNION ALL                       

  SELECT sub1.*
    from (SELECT t1.column1,                        
                 t2.column2,                        
                 t1.column3,                                                
            FROM table1 t1, table2 t2                       
            WHERE t1.column1 = t2.column1 and t1.column2 = 4    

          UNION                     

          SELECT t1.column1,                        
                 t2.column2,                        
                 t1.column3,                                                
            FROM table1 t1, table2 t2                           
            WHERE A.CAL = B.CAL and a.type = 4                      
            and (t1.column1 not like '%ABC%)) sub1;

理想情况下,两个查询应该给出相同的结果,但我发现两个查询中的计数不匹配。我不明白我错在哪里?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题