select a.病人字段 , b.* from patientinfo a, patientcaseinfo b where a.npid = b.npid
还是?
select a.病人字段 , b.* from patientinfo a, patientcaseinfo b where a.patient = b.npid

解决方案 »

  1.   

    select 
    *
    from 病例表 a
    where
    (select count(1) from 病人表 where 病例ID=a.ID)>1
      

  2.   

    好像看明白了,是查有两个病例及以上的病人
    select * from patientinfo where npid in 
    (select npid from patientcaseinfo group by npid having count(*) > 1)
      

  3.   

    用group by 过程病例表,再用此子查询与病人表连接查询
      

  4.   


    --这样?
    select a.name , count(*) 个数 
    from patientinfo a , patientcaseinfo b 
    where a.npid = b.npid
    group by name 
      

  5.   

    最后一问
    谢谢
    你这边列出了每个病人对应的病例个数
    我现在只想要病例个数>5的改怎么写?还有我只要病例个数>5的病人的数量马上结贴!谢谢潇洒老乌龟