所有累计次数:
            sql = "SELECT Count(id) AS WeightNum FROM tb_overrun WHERE  month(tb_CreateDate)='" + DateTime.Now.Month + "' and day(tb_CreateDate)='" + DateTime.Now.Day + "'";
累计出错01次数
            sql = "SELECT Count(id) AS WeightNum FROM tb_overrun WHERE  month(tb_CreateDate)='" + DateTime.Now.Month + "' and day(tb_CreateDate)='" + DateTime.Now.Day + "' and tb_TypeOverrun='" + sOverrun + "'";
累计出错02次数
            sql = "SELECT Count(id) AS WeightNum FROM tb_overrun WHERE  month(tb_CreateDate)='" + DateTime.Now.Month + "' and day(tb_CreateDate)='" + DateTime.Now.Day + "' and (tb_TypeHeight='超高' or tb_TypeWidth='超宽'  or tb_TypeLong='超长')";
语句我自己都做出来!!但是如何把不同的统计内容一次查询出来!!因为要使用报表,所以....

解决方案 »

  1.   

    以前使用mssql的方法都用不了!mysql第一次使用!!
      

  2.   

    UNION
    == 思想重于技巧 ==
      

  3.   

    用union all如:select * from A 
    union all
    select * from B
    union all
    select * from C
      

  4.   

    A B C 要查询的内容都是一个表的还有如何传值到查询!如:
    SELECT AA='2008-12-12',BB='2008-12-13',T.AA,T.BB,T.CC FROM T
      

  5.   

    SELECT '2008-12-12' as AA,'2008-12-13' as BB,T.AA,T.BB,T.CC FROM T 
    == 思想重于技巧 ==
      

  6.   

    sql = "SELECT Count(id) AS WeightNum FROM tb_overrun WHERE month(tb_CreateDate)='"   DateTime.Now.Month   "' and day(tb_CreateDate)='"   DateTime.Now.Day   "'"; 
    sql = sql   " union all "
    sql = "SELECT Count(id) AS WeightNum FROM tb_overrun WHERE month(tb_CreateDate)='"   DateTime.Now.Month   "' and day(tb_CreateDate)='"   DateTime.Now.Day   "' and tb_TypeOverrun='"   sOverrun   "'"; 
    sql = sql   " union all "
    sql = "SELECT Count(id) AS WeightNum FROM tb_overrun WHERE month(tb_CreateDate)='"   DateTime.Now.Month   "' and day(tb_CreateDate)='"   DateTime.Now.Day   "' and (tb_TypeHeight='超高' or tb_TypeWidth='超宽' or tb_TypeLong='超长')"; 
    sql = sql   " order by 1 desc "row1 所有累计次数:
    row2  累计出错01次数 
    row3  累计出错02次数
    == 思想重于技巧 ==
      

  7.   

    SELECT '2008-12-19' AS Fdate,'2008-12-20' as Tdate FROM tb_overrun
    union
    SELECT   Count(id)   AS   WeightNum   FROM   tb_overrun 
    WHERE   month(tb_CreateDate)='4'   and   day(tb_CreateDate)='4'
      

  8.   

    SELECT   Count(id)   AS   WeightNum, '2008-12-19' AS Fdate,'2008-12-20' as Tdate  FROM   tb_overrun 
    WHERE   month(tb_CreateDate)='1'   and   day(tb_CreateDate)='14'
    union   all
    SELECT   Count(id)   AS   WeightNum ,'2008-12-19' AS Fdate,'2008-12-20' as Tdate   FROM   tb_overrun  
    WHERE   month(tb_CreateDate)='1'   and   day(tb_CreateDate)='14'  and   tb_TypeOverrun='超越'原来要这样!