求一条sql语句。创建的表都有了。现在根据要求来得到输出。解决方法

求一条sql语句。创建的表都有了。现在根据要求来得到输出。
create table tmp_table(
  id varchar2(10),
  name varchar2(40),
  flag varchar2(1)
)

创建表的语句。数据
insert into tmp_table (ID, NAME, FLAG) values ('1', '小明', '0'); 
insert into tmp_table (ID, NAME, FLAG) values ('2', '小明', '1'); 
insert into tmp_table (ID, NAME, FLAG) values ('4', '小华', '0'); 
insert into tmp_table (ID, NAME, FLAG) values ('5', '小强', '1'); 
insert into tmp_table (ID, NAME, FLAG) values ('6', '小玲', '1'); 
insert into tmp_table (ID, NAME, FLAG) values ('7', '小红', '0'); 
insert into tmp_table (ID, NAME, FLAG) values ('8', '小红', '1'); 
现在想查询出来的数据是
小明 和小红。
因为小明和小红的flag 标记既有‘0’,也有‘1’。求这样一个语句。
其他的人员要么只有‘1’,要么只用‘0’。


------解决方案--------------------
select distinct(a.name) from tmp_table a, tmp_table b
where a.name = b.name
and ((a.flag = 0 and b.flag = 1)
or (a.flag = 1 and b.flag = 0));
------解决方案--------------------
SQL code
select distinct a.name from tmp_table a, tmp_table b where a.name=b.name and a.flag<>b.flag

------解决方案--------------------
再给一个
SQL code
select t.name 
from(select name , count(*)-sum(flag) c1,count(*) c2 from tmp_table group by name)t 
where t.c1<>t.c2 and t.c1>0

------解决方案--------------------
SQL code

SELECT t.NAME FROM t
GROUP BY t.NAME
HAVING SUM(DECODE(t.flag,'0',1,0)) > 0 AND SUM(DECODE(t.flag,'1',1,0)) > 0

------解决方案--------------------
要查询什么呢?