select t.sjly,t1.kkmc,t.fxbh,t.cdbh,t.whichday,t.whichhour,'' as whichmin,
round(avg(t.avgspeed),1) avgspeed,sum(t.flow) flow ,sum(t.bigcar),sum(t.smallcar) smallcar from flow t join kkxx t1 
on t.kkbh = t1.kkbh where whichday='2011-01-06'
group by t.sjly,t1.kkmc,t.fxbh,t.cdbh,t.whichday,t.whichhour 我用上面这条语句查出有23条记录,我想查出总记录数,用下面这条语句不行,查出的也是23条记录,那怎么写sql语句呢。select count(*) from flow t join kkxx t1 
on t.kkbh = t1.kkbh where whichday='2011-01-06'
group by t.sjly,t1.kkmc,t.fxbh,t.cdbh,t.whichday,t.whichhour 

解决方案 »

  1.   


    就是求查询结果的总记录数,怎么不明白呢。
    比如说select count(*) from table t
    这就是求表t的总记录数。而我的第二条语句查询的是这样一个结果行号         count(*)
    1 11
    2 12
    3 11
    4 12
    5 12
    6 9
    7 12
    8 4
    9 12
    10 12
    11 12
    12 12
    13 12
    14 12
    15 12
    16 12
    17 11
    18 12
    19 12
    20 9
    21 12
    22 12
    23 12
     
      

  2.   

    select count(1) from 
    (
      select ... from ..
    ) m
      

  3.   

    不行的原因是因为你的count(*)和group by在同一级,所以,你只需要在外层做个子查询就可以了啊
    select count(*) from (....你的sql文)