请问sql server分组后怎样能让只要其中一组数据满足where后面的多个条件之中一个就提取出来

比如:a表

  • ID cid tid
  • 1 1 1
  • 2 1 5
  • 3 2 1
  • 4 2 2

要挑选tid在{1,2,3}和{4,5,6}之间的cid,那么cid=1输出,cid=2排除,这样sql怎么写?

select t1.cid from a t1,a t2 where t1.tid in('1','2','3') and t2.tid in('4','5','6') and t1.cid=t2.cid

tid在{1,2,3}和{4,5,6}之间的cid,123,456中间还有啥整数啊。没明白你的意思。不知道你是不是要描述这么个意思哈。
select cid from t1 where tid between 1 and 6 and cid=1