求一句SQL语句
------------------
归档
2007年05月(4)
2007年04月(9)
2007年03月(14)
2007年02月(17)
2007年01月(18)
--------------------------
在博客里有这个归档,SQL语句怎么实现???
============================================
我的数据表为:
二、博客文章bk_wz
  w_id
  w_name 文章名称
  w_nr  文章内容
  w_time 发布时间

解决方案 »

  1.   

    bk_wz
    w_id
    w_name 文章名称
    w_nr 文章内容
    w_time 发布时间
    这些都是表名?
      

  2.   

    select 年月,count(年月) from table  group by 年月 order by 年月 desc年月需要从发布时间里提取
      

  3.   

    select convert(varchar(10),w_time,120),count(*) from bk_wz group by convert(varchar(10),w_time,120) order by convert(varchar(10),w_time,120)
      

  4.   

    回oldmoon(电子商务人,电子商务路) :
    ---------------
    二、博客文章bk_wz
      1、w_id  ----------文章ID
      2、w_name   ----------文章名称
      3、w_nr   ------------文章内容
      4、w_time  ----------发布时间
    ===============================
    回yiyioo(天一(一个人的Team)) :
    怎么提取啊?
      

  5.   

    select sum(id) from news group by date
      

  6.   

    select replace(convert(varchar(7),w_time,120),'-','年') + '月',count(*) num 
       from bk_wz
       group by convert(varchar(7),w_time,120)
      

  7.   

    select convert(varchar(7),w_time,120),count(*) from bk_wz group by convert(varchar(7),w_time,120) order by convert(varchar(7),w_time,120)
      

  8.   

    DataBinder.Eval:“System.Data.DataRowView”不包含名称为 w_time 的属性。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Web.HttpException: DataBinder.Eval:“System.Data.DataRowView”不包含名称为 w_time 的属性。
      

  9.   

    select convert(varchar(7),w_time,120),count(*) from bk_wz group by convert(varchar(7),w_time,120) order by convert(varchar(7),w_time,120)
    ======================================
    使用这个语句,就出现上面的错误。
    w_time 这个字段是有的
      

  10.   

    很明显你自己绑定时列名的问题.
    简单,给列个别名就可以了select replace(convert(varchar(7),w_time,120),'-','年') + '月' w_time,count(*) num 
       from bk_wz
       group by convert(varchar(7),w_time,120)
      

  11.   

    <asp:datagrid id="DataGrid2" runat="server" GridLines="None" CellPadding="0" AutoGenerateColumns="False"
    ShowHeader="False">
    <Columns>
    <asp:TemplateColumn>
    <ItemTemplate>
    <%# DataBinder.Eval(Container, "DataItem.w_time","{0:Y}") %>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:datagrid>
    -------------------------------------
    SqlConnection MyConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["connectionString"]);
    string strSel1 = "select convert(varchar(7),w_time,120) from bk_wz group by convert(varchar(7),w_time,120) order by convert(varchar(7),w_time,120)";
    DataSet MyDataSet = new DataSet();
    SqlDataAdapter myCommand = new SqlDataAdapter(strSel1,MyConnection);
    myCommand.Fill(MyDataSet,"999");
    this.DataGrid2.DataSource = MyDataSet;
    this.DataGrid2.DataBind();
    =============================================
    代码如上,还是出现上面的错,请教错在哪儿?
      

  12.   

    string strSel1 = "select replace(convert(varchar(7),w_time,120),'-','年') + '月' w_time,count(*) num from bk_wz group by convert(varchar(7),w_time,120)";
    -----------------------------------------------------
    用上面这个语句,出现以下出错:
    --------------------------------------------
    列 'bk_wz.w_time' 在选择列表中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中。
      

  13.   

    string strSel1 = "select replace(convert(varchar(7),w_time,120),'-','年') + '月' w_time,count(*) num from bk_wz group by select replace(convert(varchar(7),w_time,120),'-','年') + '月' ";
      

  14.   

    打多了个SELECT。把最后面的SELECT去掉
      

  15.   

    恩,可以了
    非常感谢fcuandy
    --------------------------------
    还有个问题,
    Request.QueryString["w_time"]
    传的参数是w_time=2007年05月
    怎么在显示列表读出来呢?
    即SQL语句怎么写啊?
    select * from bk_wz where w_time= '"+Request.QueryString["t_time"]+ "' ORDER BY w_time DESC";
      

  16.   

    select * from bk_wz where convert(varchar(7),w_time,120)= '"+Request.QueryString["t_time"].ToString().Replace(....把年替换成-,把月替换掉)+ "' ORDER BY w_time
      

  17.   

    c#中的字串的replace方法你不会用?
      

  18.   

    where convert(varchar(6),w_time,112)= '"+Request.QueryString["t_time"].ToString().Replace("年","").Replace("月","")+