0

我有两个日期时间选择器,我从这些日期时间选择器中选择范围以从表中检索信息,但我得到错误,因为它计算所有图像并给我单个日期的计数,而不是按日期计算。

MySqlDataAdapter sda = new MySqlDataAdapter(String.Format(
      "SELECT   datetime ," +
      "sum(CASE action when '2' then 1 else 0 end) as AcceptedIMG, " +
      "sum(CASE action when '3' then 1 else 0 end) as RejectedIMG, " +
      "sum(CASE action when '4' then 1 else 0 end) as ChangeIMG " +
      "FROM customer_1.audit_trail " +
      //"GROUP BY (dateonly)" +
     // "ORDER BY  (dateonly) asc  " +
      "where datetime BETWEEN '{0}' and '{1}'",
      start.Value.ToString("yyyy/MM/dd"), 
      end.Value.ToString("yyyy/MM/dd"),
      "GROUP BY (datetime)" ), conn);
                sda.Fill(db);

                dataGridView1.DataSource = db;
4

0 回答 0