Foxtable(狐表)用户栏目专家坐堂 → 多表汇集及查询


  共有10414人关注过本帖树形打印复制链接

主题:多表汇集及查询

帅哥哟,离线,有人找我吗?
nblwar
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:977 积分:6806 威望:0 精华:1 注册:2012/8/7 22:03:00
  发帖心情 Post By:2012/12/17 12:40:00 [显示全部帖子]

自己编码生成临时表来统计

        Dim dtb As New DataTableBuilder("坯料统计")
        dtb.AddDef("客户", Gettype(String), 16)
        dtb.AddDef("合金", Gettype(String), 16)
        dtb.AddDef("坯料规格", Gettype(String), 30)
        dtb.AddDef("生产批号", Gettype(String), 30)
        dtb.AddDef("总数", Gettype(Integer))
        dtb.AddDef("当前规格_7", Gettype(Integer),"","7.0")
        dtb.AddDef("当前规格_4", Gettype(Integer),"","4.0")
        dtb.AddDef("当前规格_18", Gettype(Integer),"","1.8")
        dtb.AddDef("当前规格_18Q", Gettype(Integer),"","1.8已切")
        dtb.AddDef("当前规格_1", Gettype(Integer),"","1.0")
        dtb.AddDef("当前规格_05", Gettype(Integer),"","0.5")
        dtb.AddDef("当前规格_03", Gettype(Integer),"","0.3")
        dtb.Build()
        For Each nm() As String In DataTables("坯料跟踪表").GetUniqueValues("","客户","合金","坯料规格","生产批号")
            Dim dr As DataRow = DataTables("坯料统计").AddNew()
            dr("客户") = nm(0)
            dr("合金") = nm(1)
            dr("坯料规格") = nm(2)
            dr("生产批号") = nm(3)
            dr("当前规格_7") = DataTables("坯料跟踪表").Compute("COUNT(熔铸编号)","[客户] = '" & nm(0) & "' And [合金] = '" & nm(1) & "' And [坯料规格] = '" & nm(2) & "' And [生产批号] = '" & nm(3) & "' And [当前规格] = '7.0'")
            dr("当前规格_4") = DataTables("坯料跟踪表").Compute("COUNT(熔铸编号)","[客户] = '" & nm(0) & "' And [合金] = '" & nm(1) & "' And [坯料规格] = '" & nm(2) & "' And [生产批号] = '" & nm(3) & "' And [当前规格] = '4.0'")
            dr("当前规格_18") = DataTables("坯料跟踪表").Compute("COUNT(熔铸编号)","[客户] = '" & nm(0) & "' And [合金] = '" & nm(1) & "' And [坯料规格] = '" & nm(2) & "' And [生产批号] = '" & nm(3) & "' And [当前规格] = '1.8'")
            dr("当前规格_18Q") = DataTables("坯料跟踪表").Compute("COUNT(熔铸编号)","[客户] = '" & nm(0) & "' And [合金] = '" & nm(1) & "' And [坯料规格] = '" & nm(2) & "' And [生产批号] = '" & nm(3) & "' And [当前规格] = '1.8Q'")
            dr("当前规格_1") = DataTables("坯料跟踪表").Compute("COUNT(熔铸编号)","[客户] = '" & nm(0) & "' And [合金] = '" & nm(1) & "' And [坯料规格] = '" & nm(2) & "' And [生产批号] = '" & nm(3) & "' And [当前规格] = '1.0'")
            dr("当前规格_05") = DataTables("坯料跟踪表").Compute("COUNT(熔铸编号)","[客户] = '" & nm(0) & "' And [合金] = '" & nm(1) & "' And [坯料规格] = '" & nm(2) & "' And [生产批号] = '" & nm(3) & "' And [当前规格] = '0.5'")
            dr("当前规格_03") = DataTables("坯料跟踪表").Compute("COUNT(熔铸编号)","[客户] = '" & nm(0) & "' And [合金] = '" & nm(1) & "' And [坯料规格] = '" & nm(2) & "' And [生产批号] = '" & nm(3) & "' And [当前规格] = '0.3'")
            dr("总数") = DataTables("坯料跟踪表").Compute("COUNT(熔铸编号)","[客户] = '" & nm(0) & "' And [合金] = '" & nm(1) & "' And [坯料规格] = '" & nm(2) & "' And [生产批号] = '" & nm(3) & "'")
        Next


 回到顶部