zoukankan      html  css  js  c++  java
  • DataTable中进行Distinct、Group by、Join、Create

    Code
    using System; 
    using System.Collections; 
    using System.Data; 
     
    namespace Common 

        
    /**//**//**//// <summary> 
        
    /// DataSet助手 
        
    /// </summary> 

        public class DataSetHelper 
        

            
    private class FieldInfo 
            

                
    public string RelationName; 
                
    public string FieldName; 
                
    public string FieldAlias; 
                
    public string Aggregate; 
            }
     
     
            
    private DataSet ds; 
            
    private ArrayList m_FieldInfo; 
            
    private string m_FieldList; 
            
    private ArrayList GroupByFieldInfo; 
            
    private string GroupByFieldList; 
     
            
    public DataSet DataSet 
            

                
    get return ds; } 
            }
     
     
            ConstructionConstruction
    Construction 
     
            Private MethodsPrivate Methods
    Private Methods 
     
            SelectDistinct 
    / DistinctSelectDistinct / DistinctSelectDistinct / Distinct 
     
            Select Table IntoSelect Table Into
    Select Table Into 
     
            Group By TableGroup By Table
    Group By Table 
     
            Join TablesJoin Tables
    Join Tables 
     
            Create TableCreate Table
    Create Table 
        }
     
    }

    调用:
    dt = dsHelper.SelectGroupByInto("OrderSummary", ds.Tables["Employees"],
        "EmployeeID,sum(Amount) Total,min(Amount) Min,max(Amount) Max", "EmployeeID<5", "EmployeeID");

    此调用示例创建新 DataTable 具有四个字段 (EmployeeID、 总计、, Min 和 Max) 以及 OrderSummary TableName 。 这些四个字段具有相同数据类型, EmployeeID 和 Orders 表中数量字段。 然后本示例从 Orders DataTable , 读取记录并将记录写入 OrderSummary DataTable 。 OrderSummary DataTable 包含 EmployeeID 域和三个不同的聚合的金额字段上筛选, EmployeeID EmployeeID 5 和, 是上分组 (和按) < "。 如果 GroupBy 参数是空白, DataTable 目标包含聚合所有输入仅单个记录。

    参考地址:http://support.microsoft.com/kb/326145
    http://topic.csdn.net/t/20060514/14/4750499.html
  • 相关阅读:
    Link Maker 为 Apple Music、iTunes Store、App Store、iBooks Store 以及 Mac App Store 创建链接。
    在 CentOS7 上安装 MySQL5.7
    Git关于忽略Xcode工程中UserInterfaceState.xcuserstate文件的问题
    UITableView的frame改变做动画时,如何禁用UITableViewCell内置的动画效果
    Error: You must `brew link pcre openresty-openssl` before homebrew/nginx/openresty can be installed
    resty.upload 处理上传的图片 并把生成的url保存到数据库中
    Lua 计算两个GPS坐标点之间的距离
    Cornerstone安装提示文件已损坏问题
    "xxx was built without full bitcode" 编译错误解决
    iOS 网页打开APP,并且跳转到对应界面
  • 原文地址:https://www.cnblogs.com/xlfj521/p/1120864.html
Copyright © 2011-2022 走看看