select count(*) from (select CNId from WorkFlow group by CNId)
                   这样写是不对的  那如何才能达到这样滴效果呢 查结果集的总条数

解决方案 »

  1.   

    select count(distinct CNId) from WorkFlow
      

  2.   

    select count(distinct CNId) from WorkFlow
      

  3.   

    select count(distinct CNId) from WorkFlow你原来那个应该是这样select count(*) from (select CNId from WorkFlow group by CNId)t --加个t还是用我写的吧,更直接
      

  4.   

    declare @CNId nvarchar(50)select @CNId=CNId from WorkFlow group by CNId这样后如何去循环呢@CNId
      select startTime from WorkFlow where CNId=  ?
      

  5.   

    select count(*) from (select CNId from WorkFlow group by CNId) aFrom 后面要加,作为一个结果集,然后才能统计
      

  6.   

    循环处理startTime ?
    数据量小用游标吧
      

  7.   

    要么自己写while 条件
    select startTime from WorkFlow where CNId=要么就游标
      

  8.   

    select count(*) from (select CNId from WorkFlow group by CNId) TB
    因为你少了个子查询充当表的别名。加上红色部分就可以了。
      

  9.   

    问个问题:
    在数据库中编写代码如下:
    declare @sql varchar(5000)
    begin
    set @sql='select mycolumn as ''中文'' from mytable'
    exec(@sql)
    end
    列名显示??
    怎样才能正常显示中文列名(必须是拼写sql的形式)
      

  10.   

    select count(*) from (select CNId from WorkFlow group by CNId) T
    这样写就对了!
      

  11.   

    select count(*) from (select CNId from WorkFlow group by CNId) tb
    加个别名
      

  12.   

    http://topic.csdn.net/u/20101208/10/7da17e9a-6ef6-49a4-93f2-5f7482fe961d.html
       看看这个帖
      

  13.   

    select count(*) from (select CNId from WorkFlow group by CNId)t