开发日志:按照每月每天,每年每月,每月每周汇总数据

按每月每日

public  DataSet MonthDayList(DateTime dt)
    {
        StringBuilder strSql 
=   new  StringBuilder();
        strSql.Append(
" Select DateNum,PlanID,Sum(DayClick) As SumCount,DateUpdated  " );
        strSql.Append(
" From vA4_SumDayCount  " );
        strSql.Append(
" Where DateDiff(Month,DateUpdated,@dt) = 0  " );
        strSql.Append(
" And PlanID = @PlanID Group By DateNum,PlanID,DateUpdated  " );
        strSql.Append(
" Order By DateNum DESC " );
        SqlParameter[] p 
=  {
                               SqlHelper.MakeInParam(
" @dt " , SqlDbType.DateTime,  8 , dt),
                               SqlHelper.MakeInParam(
" @PlanID " , SqlDbType.Int,  4 , _ID)
                           };
        
return  SqlHelper.ExecuteDataset(clsConfig.conn, CommandType.Text, strSql.ToString(), p);
    }


按每月每周

public  DataSet MonthWeekList(DateTime dt)
    {
        StringBuilder strSql 
=   new  StringBuilder();
        strSql.Append(
" Select CAST(DATEPART(wk, DateUpdated) AS VARCHAR) AS DateWeek,Sum(DayClick) AS SumCount  " );
        strSql.Append(
" From vA4_SumdayCount Where PlanID = @PlanID And DateDiff(Year,DateUpdated,@dt) = 0 " );
        strSql.Append(
" Group By CAST(DATEPART(wk, DateUpdated) AS VARCHAR) Order By DateWeek DESC " );
        SqlParameter[] p 
=  {
                               SqlHelper.MakeInParam(
" @PlanID " , SqlDbType.Int,  4 , _ID),
                               SqlHelper.MakeInParam(
" @dt " , SqlDbType.DateTime,  8 , dt)
                           };
        
return  SqlHelper.ExecuteDataset(clsConfig.conn, CommandType.Text, strSql.ToString(), p);
    }

按每年每月
public  DataSet YearMonthList(DateTime dt)
    {
        StringBuilder strSql 
=   new  StringBuilder();
        strSql.Append(
" Select SUBSTRING(CAST(DateNum AS VARCHAR), 1, 6) AS DateMonth,Sum(DayClick) AS SumCount  " );
        strSql.Append(
" From vA4_SumdayCount Where PlanID = @PlanID And DateDiff(Year,DateUpdated,@dt) = 0  " );
        strSql.Append(
" Group by SUBSTRING(CAST(DateNum AS VARCHAR), 1, 6)  " );
        strSql.Append(
" Order By DateMonth DESC " );
        SqlParameter[] p 
=  {
                               SqlHelper.MakeInParam(
" @PlanID " , SqlDbType.Int,  4 , _ID),
                               SqlHelper.MakeInParam(
" @dt " , SqlDbType.DateTime,  8 , dt)
                           };
        
return  SqlHelper.ExecuteDataset(clsConfig.conn, CommandType.Text, strSql.ToString(), p);
    }





你可能感兴趣的:(日志)