本文共 1104 字,大约阅读时间需要 3 分钟。
然后你就可以写你要执行的一系列代码了,我的比较简单,有比较复杂的请自行百度
Private Sub Command0_Click()
str1 = "create table result(NewID char(255),DoAdmit Date,DoDischarge Date,Interval long)"
str2 = "insert into result(NewID,DoAdmit)select distinct NewID,(select max(DoAdmit) from 2002table b where b.NewID = a.NewID) as DoAdmit from ( select NewID from 2002table group by NewID having count(NewID)>1) a"
str3 = "select NewID,(select max(DoDischarge) from 2002table a where a.NewID = r.NewID And a.DoAdmit = r.DoAdmit) as DoDischarge into t from result r"
str4 = "select b.NewID, (select top 1 DoDischarge from 2002table a where a.NewID = b.NewID And a.DoDischarge <> b.DoDischarge order by DoDischarge desc) as DoDischarge into t1 from t b "
str5 = "UPDATE result a,t1 b Set a.DoDischarge = b.DoDischarge WHERE a.NewID = b.NewID"
str6 = "update result set interval=doadmit-dodischarge"
str7 = "drop table t"
str8 = "drop table t1"
CurrentDb.Execute (str1)
CurrentDb.Execute (str2)
CurrentDb.Execute (str3)
CurrentDb.Execute (str4)
CurrentDb.Execute (str5)
CurrentDb.Execute (str6)
CurrentDb.Execute (str7)
CurrentDb.Execute (str8)
End Sub
转载地址:http://yekdy.baihongyu.com/