日期:2014-05-17 浏览次数:20758 次
--各疾病的检出总人数可以这样来统计
select t1.sMC as 疾病名称,count(distinct sGRDAH) as 检出总人数
from jgb t1,CJZDB t2,RYDJB t3
where CHARINDEX(t2.sBM,t1.sZDMC)>0 and t3.sGRDAH=t1.sGRDAH
group by t1.sBM,t1.sMC
--年龄分布的就好办了
--<45岁的
select t1.sMC as 疾病名称,count(distinct sGRDAH) as 检出总人数
from jgb t1,CJZDB t2,RYDJB t3
where CHARINDEX(t2.sBM,t1.sZDMC)>0 and t3.sGRDAH=t1.sGRDAH
and t3.iNL<=45
group by t1.sBM,t1.sMC
--剩下的依次类推
CREATE TABLE #RYDJB(ID INT IDENTITY,姓名 NVARCHAR(10), 性别 NCHAR(1), 年龄 INT, sGRDAH VARCHAR(20))
INSERT #RYDJB (姓名, 性别, 年龄, sGRDAH )
SELECT '张三', '女', 23, '20130600434' UNION ALL
SELECT '李四', '男', 23, '20130600435' UNION ALL