哦,我写的有问题父id为‘a’。

解决方案 »

  1.   

    不是4个吗?declare @a table(id varchar(10),父id varchar(10))
    declare @b table(id varchar(10),业绩 int)
    insert @a
    select 'a','a' union
    select 'b','a' union
    select 'c','a' union
    select 'd','a' 
    insert @b
    select 'a',5 union 
    select 'b',5 union
    select 'c',5 union
    select 'd',5 --查询
    select count(id) as '人数'
    from @b 
    where id in (select id from @a where 父id = 'a') 
          and 业绩 >= 5--结果
    /*
    人数          
    ----------- 
    4(1 row(s) affected)
    */