把两个查询数据接起来
select * from (
(
select id,instiname,myTB.reportMan,username,(select count(*) from stocks s where s.instiname = myTB.instiname and myTB.reportMan ='' ) as 'gupiao',
(select count(*) from PlateDb p where p.instiname = myTB.instiname and p.ItemId = 10 and myTB.reportMan ='') as '10',(select count(*) from PlateDb p
where p.instiname = myTB.instiname and p.ItemId = 9 and myTB.reportMan ='') as '9'from Mycustom myTB where UserName='w'and reportMan =''
)UNION(
select id,instiname,myTB.reportMan,username,
(select count(*) from stocks s where s.instiname = myTB.instiname and s.reportMan like '%'+myTB.reportMan+'%') as 'gupiao',(select count(*) from PlateDb p where p.instiname = myTB.instiname
and p.ItemId = 10 and p.reportMan like '%'+myTB.reportMan+'%') as '10',(select count(*) from PlateDb p where p.instiname = myTB.instiname and p.ItemId = 9 and p.reportMan =myTB.reportMan) as '9'
from Mycustom myTB where UserName='w'and reportMan <>'' )
) tb order by instiname DESC