Oracle怎么查询一个字段对应不重复的数据且唯一。

img


如图,查询num为0且只为0的数据,type为1对应的只有一个0所以满足条件可以查询,type为10的对应num为“0,3,4”,因为num不是唯一为0所以不满足。
同理,type为1001和1002也满足。
请问怎么进行查询,谢谢。

你可以嵌套查询
内层先进行select type,min(num) as num,count(*) as c from table group by type
这样查出来的会把相同type值合并,并且列名c里是个数
外层再查c=1且num=0的数据

select type from (select type,wm_concat(num) wcon from tablename group by type) t where wcon=0