你也没给表
我就按自己想法来了
表如图
答案按1,2,3,4的顺序来,猜对的话为1,猜错的话为0
1
select a.姓名 from test as a where a.场次=1 and a.猜对比分='1' and exists (select 1 from test as b where b.场次=2 and b.猜对比分='1' and a.姓名=b.姓名)
2
select a.姓名 from test as a where a.场次=1 and a.猜对比分='1' and exists (select 1 from test as b where b.场次=2 and b.猜对胜负='1' and a.姓名=b.姓名)
union
select a.姓名 from test as a where a.场次=2 and a.猜对比分='1' and exists (select 1 from test as b where b.场次=1 and b.猜对胜负='1' and a.姓名=b.姓名)
3
select a.姓名 from
(select 姓名 from test where 猜对胜负='1' and 场次=1) as a,
(select 姓名 from test where 猜对胜负='2' and 场次=1) as b
where a.姓名=b.姓名
4
select a.姓名 from
(select 姓名 from test where 猜对胜负='1' and 场次=1) as a,
(select 姓名 from test where 猜对胜负<>'1' and 场次=2) as b
where a.姓名=b.姓名
union all
select a.姓名 from
(select 姓名 from test where 猜对胜负<>'1' and 场次=1) as a,
(select 姓名 from test where 猜对胜负='1' and 场次=2) as b
where a.姓名=b.姓名