select b.PoverplaceCode from D表 a Join 途经地表 b on a.Id=b.fluxid where PoutplaceCode='山西' and PinplaceCode='北京'
select COUNT(*) from 途径地表 where fluxid IN (select id from d where poutolacecode='北京' and pinplacecode='山西')
也许是我没说清楚,我要进行的分类汇总比这个复杂多了。下面的语句是我写得sqlSELECT a.PoutplaceCode,a.AoutplaceCode,a.PinplaceCode,a.AinplaceCode,count(*) as num,SUM(a.drugweight) as totalweight,SUM(b.suspectnum) as allsuspect FROM drugflux as a,solvedcase as b where a.keys<>0 and a.keys<>2 and a.solvedcaseid=b.unqid and b.keys<>3 group by a.PoutplaceCode,a.AoutplaceCode,a.PinplaceCode,a.AinplaceCode order by totalweight desc 现在涉及了两个表solvedcase、drugflux。事实上应该还有一个途经地表(overplace),现在我不太清楚怎么用以上的sql来统计overplace中与drugflux的unqid对应的途经地个数求出来?
from D表 a Join
途经地表 b on a.Id=b.fluxid
where PoutplaceCode='山西' and PinplaceCode='北京'
现在涉及了两个表solvedcase、drugflux。事实上应该还有一个途经地表(overplace),现在我不太清楚怎么用以上的sql来统计overplace中与drugflux的unqid对应的途经地个数求出来?