请问这个select怎么写?谢谢

chenlm 2003-09-08 04:00:05
table: t1
f1 f2
2 10
3 9
5 13
6 11
3 11
5 8
7 9
3 8

请问如何选择出f1有相同的
比如上面的就选择出

f1 f1
3 8
3 9
3 11
5 8
5 13

谢谢~~
...全文
23 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
bitfubin 2003-09-08
  • 打赏
  • 举报
回复
select * from t1 where f1 in (select f1 from t1 group by f1 having sum(1)>1)
chenlm 2003-09-08
  • 打赏
  • 举报
回复
table: t1
f1 f2 f3
2 10 1
3 9 1
5 13 1
6 11 1
3 11 1
5 8 1
7 9 1
3 8 2

请问如何选择出f1有相同的并且f3为1的呢?
比如上面的就选择出

f1 f2
3 9
3 11
5 8
5 13

谢谢~~
chenlm 2003-09-08
  • 打赏
  • 举报
回复
对了~~还需要同时判断 f2 = ???的情况下
pengdali 2003-09-08
  • 打赏
  • 举报
回复
select * from t1 where f1 in (select f1 from t1 group by f1 having sum(1)>1)
newly_ignorant 2003-09-08
  • 打赏
  • 举报
回复
select t1.* from t1 right join
(select f1 from t1 group by f1 having count(f1) > 1 ) as t2
on t1.f1=t2.f1 order by t1.f1,t1.f2
yujohny 2003-09-08
  • 打赏
  • 举报
回复
select * from t1 a
where f1 in (select f1 from t1 group by f1 having count(*)>1)
order by f2
sdhdy 2003-09-08
  • 打赏
  • 举报
回复
select * from t1 a where f1 in (select f1 from t1 group by f1 having count(f1)>1)
sdhdy 2003-09-08
  • 打赏
  • 举报
回复
select * from t1 a where f1 in (select f1 from t1 group by f1 having count(f1)>1)

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧