select a.Introduce,count(1) as number
from A表 a inner join B表 on a.Introduce=b.Introduce
inner join C表 c on b.Obj_Id=c.Obj_Id
where Level>5
group by a.Introduce
create table a (Main_ID varchar(200),Introduce varchar(200))
create table b (Obj_ID varchar(200),Introduce varchar(200),Main_ID varchar(200))
create table c (ID varchar(200),Obj_ID varchar(200),level varchar(200))
insert a
select '1','abc' union all
select '2','dbc'
insert b
select '1','abc','1' union all
select '2','dbc','1' union all
select '3','ddf','1'
insert c
select '1','1','5' union all
select '2','1','6'
select
count(c.level) as number
from (select * from c where level>='5') c where obj_ID in (select b.obj_id from (select * From a where Introduce='abc') a
join b on a.main_ID=b.main_ID)
--测试环境
Create table A表(Main_ID int,Introduce varchar(10))
insert into A表 select 1,'abc'
union all select 2,'bdc'
Create table B表(Obj_ID int,Introduce varchar(10),Main_Id int)
insert into B表 select 1,'abc',1
union all select 2,'bdc',1
union all select 3,'ddf',1
Create table C表(ID int,Obj_Id int,Level int)
insert into C表 select 1,1,5
union all select 2,1,6
--查询
select
Introduce=A.Introduce,
Level=count(Level)
from A表 A inner join B表 B
on A.Introduce=B.Introduce
inner join C表 C
on B.Obj_ID=C.Obj_Id
and C.Level>5
group by A.Introduce
Order by A.Introduce
select
Introduce=A.Introduce,
Level=count(Level)
from A表 A inner join B表 B
on A.Introduce=B.Introduce
inner join C表 C
on B.Obj_ID=C.Obj_Id
and C.Level>5
group by A.Introduce
Order by A.Introduce