日期:2014-05-17  浏览次数:20775 次

查询语句
1种 假设ta表有 A B C 字段
  1 h001 002
  2 h001 002
  3 h001 003
  4 m333 004
要查询结果 A B C 
  1 h001 002
  2 h001 002
  3 h001 003

意思是要查询B的值相同时C的值不相同的数据。请高手帮忙
2种假设ta表有 A B 字段
  1 h001  
  2 H001  
  3 h001  
  4 m333  
要查询结果 A B  
  1 h001  
  2 H001  
  3 h001  
 意思是要查询B的值相同时不区别大小写

------解决方案--------------------
--1
select m.* from ta m where b in( 
select b from (select distinct B , C from ta) t group by b having count(1) > 1)

--2
select m.* from ta m where b in(
select b from ta group by b having count(1) > 1)