不显示删除回复显示所有回复显示星级回复显示得分回复 Group后,查询至少包含某一项以上的数据。如何查询?[

ferrari 2011-02-21 02:05:14
比如Group以后得到
A
B
C
D
。。。。。很多项数据。

有些用户有一项,有些有户有多项同。

现要求查询:
不止包含C项的用户数。

换句话说,就是要查询包括C在内的,用户数有多少。但不包括只=C的。
...全文
62 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Rotel-刘志东 2011-02-21
  • 打赏
  • 举报
回复
给出详细的表结构
O爱咋咋地O 2011-02-21
  • 打赏
  • 举报
回复

select userid from tb1 b where gup='C' and
exists(select null from tb1 a where a.userid=b.userid and gup<>'C')
ferrari 2011-02-21
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 maco_wang 的回复:]
group by 里面加上 where 条件就可以了
[/Quote]

where条件怎么写?
叶子 2011-02-21
  • 打赏
  • 举报
回复
group by 里面加上 where 条件就可以了
昵称被占用了 2011-02-21
  • 打赏
  • 举报
回复
select userid
from tab a
where 数据项='c'
and exists (
select 1 from tab
where userid = a.userid
and 数据项<>'c'
)
group by userid

22,301

社区成员

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

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