记录如
  f1  f2  f3
  a   2   9
  a   7   1
  b   2    9 
  b   7   1
  c   4    9
  c   7    3   如果记录输成    
    c 4   9 
    c 7   1  则不行
 也就是每一组两条记录    f1 相同  f2 f3 要么是29 71 要么是 49 73 如果变成29  73 则错吴
现在想找出错误的分组记录。  sql 怎么写?   

解决方案 »

  1.   

    select a.f1,f2,f3 from 
    (select f1,wm_concat(f2||f3) col from tb group by f1) a, tb b
    where a.f1 = b.f1 and col not in ('29,71','49,73');
      

  2.   

    11:06:45 tina@PRACTICE> with tb as (select 'a' f1,'2' f2,'9' f3 from dual
    11:06:52   2  union all select 'a','7','1' from dual
    11:06:52   3  union all select 'b','2','9' from dual
    11:06:52   4  union all select 'b','7','1' from dual
    11:06:52   5  union all select 'c','4','9' from dual
    11:06:52   6  union all select 'c','7','3' from dual
    11:06:52   7  union all select 'd','2','9' from dual
    11:06:52   8  union all select 'd','7','3' from dual
    11:06:52   9  )
    11:06:52  10  select a.f1,f2,f3 from
    11:06:52  11  (select f1,wm_concat(f2||f3) col from tb group by f1) a, tb b
    11:06:52  12  where a.f1 = b.f1 and col not in ('29,71','49,73');F1   F2   F3
    ---- ---- ----
    d    2    9
    d    7    3已用时间:  00: 00: 00.00