-- 作者:lrh9537
-- 发布时间:2012/11/25 11:34:00
-- 帮我修改下代码,谢谢
r("已婚未育妇女_总数") = DataTables("妇女信息").Compute("Count(_Identify)", filter & " And 结婚日期 <= #2011-10-31# And (现有男孩数 = \'0\' And 现有女孩数 = \'0\')") + DataTables("妇女信息").Compute("Count(_Identify)", filter & " And 结婚日期 <= #2011-10-31# And (现有男孩数 = \'1\' And 现有女孩数 = \'0\' or 现有男孩数 = \'0\' And 现有女孩数 = \'1\') And 末孩出生日期 > #2011-10-31# ")
要求:已婚未育妇女_总数=结婚时间在2011.10.31前子女数为0+结婚日期在2011.10.31前,并且末孩出生日期>2011.10.31的现有男孩为1或现有女孩为1的人数
[此贴子已经被作者于2012-11-25 12:08:59编辑过]
|
-- 作者:czy
-- 发布时间:2012/11/25 13:08:00
--
稍稍改了一下,应该可以通用的吧。
Dim name As String = MainTable.Name If name.Contains("村级") Then Dim dt As DataTable = DataTables("出生") Dim y,m As Integer y = name.Replace("村级","").Replace("月","").Split("年")(0) m = name.Replace("村级","").Replace("月","").Split("年")(1) Dim d As Date = New Date(y,m,1) Dim d1 As Date = New Date(y,m,Date.DaysInMonth(y,m)) MainTable.DataTable.DataRows.Clear Dim arys As List(Of String()) = dt.GetUniqueValues("", "单位名称", "组名称") For Each ary As String() In arys Dim r As Row = MainTable.AddNew r("单位") = ary(0) r("组名称") = ary(1) Dim filter As String = "单位名称 = \'" & ary(0) & "\' And 组名称 = \'" & ary(1) & "\'" r("总人口数") = DataTables("总人口").Compute("Count(_Identify)", filter & " And 出生日期 <= #" & d1 & "#") - DataTables("迁入").Compute("Count(_Identify)", filter & " And 变动日期 > #" & d1 & "#") + DataTables("迁出").Compute("Count(_Identify)", filter & " And 迁出日期 > #" & d1 & "#") + DataTables("死亡").Compute("Count(_Identify)", filter & " And 死亡日期 > #" & d1 & "#") r("出生_总数") = dt.Compute("Count(_Identify)", filter & " And 子女出生日期 >= #" & d & "# And 子女出生日期 <= #" & d1 & "#") r("出生_政策内_一孩") = dt.Compute("Count(_Identify)", filter & " And 子女政策属性 = \'政策内\' And 子女孩次 = 1 And 子女出生日期 >= #" & d & "# And 子女出生日期 <= #" & d1 & "#") r("出生_政策内_二孩") = dt.Compute("Count(_Identify)", filter & " And 子女政策属性 = \'政策内\' And 子女孩次 = 2 And 子女出生日期 >= #" & d & "# And 子女出生日期 <= #" & d1 & "#") r("出生_政策内_多孩") = dt.Compute("Count(_Identify)", filter & " And 子女政策属性 = \'政策内\' And 子女孩次 > 2 And 子女出生日期 >= #" & d & "# And 子女出生日期 <= #" & d1 & "#") r("出生_政策外_一孩") = dt.Compute("Count(_Identify)", filter & " And 子女政策属性 = \'政策外\' And 子女孩次 = 1 And 子女出生日期 >= #" & d & "# And 子女出生日期 <= #" & d1 & "#") r("出生_政策外_二孩") = dt.Compute("Count(_Identify)", filter & " And 子女政策属性 = \'政策外\' And 子女孩次 = 2 And 子女出生日期 >= #" & d & "# And 子女出生日期 <= #" & d1 & "#") r("出生_政策外_多孩") = dt.Compute("Count(_Identify)", filter & " And 子女政策属性 = \'政策外\' And 子女孩次 > 2 And 子女出生日期 >= #" & d & "# And 子女出生日期 <= #" & d1 & "#") r("元月份以来节育手术人数_总数") = DataTables("手术").Compute("Count(_Identify)", filter & " And 手术日期 >= #" & d & "# And 手术日期 <= #" & d1 & "#") r("元月份以来节育手术人数_其中_上环") = DataTables("手术").Compute("Count(_Identify)", filter & "And 手术类型 = \'带铜宫内节育器\' And 手术日期 >= #" & d & "# And 手术日期 <= #" & d1 & "#") r("元月份以来节育手术人数_其中_绝育") = DataTables("手术").Compute("Count(_Identify)", filter & "And (手术类型 = \'男性绝育术\' Or 手术类型 = \'女性绝育术\') And 手术日期 >= #" & d & "# And 手术日期 <= #" & d1 & "#") r("元月份以来节育手术人数_其中_人工流产") = DataTables("手术").Compute("Count(_Identify)", filter & "And 手术类型 = \'人工流产\' And 手术日期 >= #" & d & "# And 手术日期 <= #" & d1 & "#") \'r("已婚未育妇女_总数") = DataTables("妇女信息").Compute("Count(_Identify)", filter & " And 结婚日期 <= #" & d1 & "# And 末孩出生日期 > #" & d1 & "# and (现有男孩数 = \'0\' And 现有女孩数 = \'0\')") r("死亡人数") = DataTables("死亡").Compute("Count(_Identify)", filter & " And 死亡日期 <= #" & d1 & "#") r("自增人数") = r("出生_总数") - r("死亡人数") r("迁移_迁入人数") = DataTables("迁入").Compute("Count(_Identify)", filter & " And 变动日期 <= #" & d1 & "#") r("迁移_迁出人数") = DataTables("迁出").Compute("Count(_Identify)", filter & " And 迁出日期 <= #" & d1 & "#") r("元月份以来新婚对数") = DataTables("新婚").Compute("Count(_Identify)", filter & " And 结婚日期 >= #" & New Date(y,1,1) & "# And 结婚日期 <= #" & d1 & "#") Next Dim nr As Row = MainTable.AddNew nr("单位") = "合计" For i As Integer = 2 To MainTable.Cols.Count - 1 nr(MainTable.Cols(i).Name) = MainTable.Compute("Sum(" & MainTable.Cols(i).Name & ")") Next End If
|