sql问题刚才写错了

jemmy 2004-07-16 05:56:02
id1 id1 vALUE
11 10 b
11 10 c
11 10 a

13 10 b
13 10 f
13 10 g

14 12 d
14 12 b
14 12 j

.............
...........

得到结果
b

按ID分类 求每个分类中 b
[ c b a] [b f g] [ d b j] 的
交集 [b]
...全文
105 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jemmy 2004-07-20
  • 打赏
  • 举报
回复
没有
hudan 2004-07-16
  • 打赏
  • 举报
回复
如果有重复,先用临时表消除

create table #表(id1 int,id2 int,value varchar(50))

insert into #表
select distinct id1,id2,value from 表


select value from #表
group by value
having count(*)=(select count(*) from (select distinct id1,id2 from #表) b)

drop table #表


(我说我怎么少了两个裤衩,原来你贴到PowerBuilder 基础类板块了)
hudan 2004-07-16
  • 打赏
  • 举报
回复
如果没有重复行:

select value from 表
group by value
having count(*)=(select count(*) from (select distinct id1,id2 from 表) b)


不知道
select count(*) from (select distinct id1,id2 from 表) b
可不可以写的简单一点?
hudan 2004-07-16
  • 打赏
  • 举报
回复
有没有重复的记录,比如:
id1 id1 vALUE
11 10 b
11 10 c
11 10 c


有2条11 10 c的记录,
有没有这种情况

mittee 2004-07-16
  • 打赏
  • 举报
回复
交集就是a.id = b.id and b.id = c.id
你这个是在同一个表里,有点难度
jemmy 2004-07-16
  • 打赏
  • 举报
回复
是不是还是没写清楚????

1,075

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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