两个库中的两个表完全一样,每个表4个字段
如果表1中有5条重复数据(111111 1 11 1111)表2中有3条重复数据(111111 1 11 1111)
用什么方法可以得出表1比表2多出两条(111111 1 11 1111),结果能输出
111111 1 11 1111
111111 1 11 1111

解决方案 »

  1.   

    select top(select max(count[字段]) from where a.[字段] =a.[字段])from (select * from a,b where a.[字段] = b.[字段]) b
    没有测试的你试一试
      

  2.   

    变态要求
    MSSQL :
    declare i int
    Set i = 
    (Select count(*) from a group by 全部字段 having count(*) >1
     - 
    Select count(*) from b group by 全部字段 having count(*) > 1)Select top 2 * , count(*) from a group by 全部字段 having count(*) > 1
    我都晕了,应该不行
      

  3.   

    select 字段1,字段2,字段3,字段4,count(*) from
    (select 字段1,字段2,字段3,字段4 from 表1
    Union all
    select 字段1,字段2,字段3,字段4 from 表2) T
    Group by 字段1,字段2,字段3,字段4
    having count(*)>1