sqlservice 两表之间得到增量数据

   select * from (
            select  max(source_t) source_t, 
                [name],[sex]     
            from (
                  SELECT 1 source_t ,  
                  [name],[sex]   
            FROM table_1
            group by  
              [name],[sex]    
                  union all
                SELECT 2 source_t ,  
             [name],[sex]    
            FROM   table_2
            group by  
             [name],[sex] 
          ) TB1
          group by  
              [name],[sex]     
          having count(*)=1        
        )TB2
where source_t =1 

 

posted @ 2020-09-04 10:59  路边有一棵草  阅读(221)  评论(0编辑  收藏  举报