smhy8187

 

Access 分组统计


  public string countNotice(string ageUserName1)//不错,分组统计
  {
      int count1 = 0 ;
   c.OpenData4();
   
   string sql = "select distinct ageUserName,sum(viewCount) as ViewCount1 from noticeCount where ageUserName='"+ageUserName1+"' group by ageUserName";
   //select   distinct   代码,sum(   数量1),sum(数量2)   from   表名   group   by   代码 

   OleDbCommand cmd  = new OleDbCommand(sql,c.mdbconn4);
   OleDbDataReader dr = cmd.ExecuteReader();
   if(dr.Read())
   {
    count1 = Convert.ToInt32(dr["ViewCount1"].ToString());
   } 
   dr.Close();
   c.mdbconn4.Close();

   if(count1!=0)
   {
    return "<font color='#ff0000'>"+count1.ToString()+"</font>";
   }
   else
   {
    return "<font color='#333333'>0</font>";
   }
  
  }

posted on 2007-06-07 16:47  new2008  阅读(1034)  评论(0编辑  收藏  举报

导航