这句sql语句怎么写呢? select count(*) from (select CNId from WorkFlow group by CNId) 这样写是不对的 那如何才能达到这样滴效果呢 查结果集的总条数 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select count(distinct CNId) from WorkFlow select count(distinct CNId) from WorkFlow select count(distinct CNId) from WorkFlow你原来那个应该是这样select count(*) from (select CNId from WorkFlow group by CNId)t --加个t还是用我写的吧,更直接 declare @CNId nvarchar(50)select @CNId=CNId from WorkFlow group by CNId这样后如何去循环呢@CNId select startTime from WorkFlow where CNId= ? select count(*) from (select CNId from WorkFlow group by CNId) aFrom 后面要加,作为一个结果集,然后才能统计 循环处理startTime ?数据量小用游标吧 要么自己写while 条件select startTime from WorkFlow where CNId=要么就游标 select count(*) from (select CNId from WorkFlow group by CNId) TB因为你少了个子查询充当表的别名。加上红色部分就可以了。 问个问题:在数据库中编写代码如下:declare @sql varchar(5000)beginset @sql='select mycolumn as ''中文'' from mytable'exec(@sql)end列名显示??怎样才能正常显示中文列名(必须是拼写sql的形式) select count(*) from (select CNId from WorkFlow group by CNId) T这样写就对了! select count(*) from (select CNId from WorkFlow group by CNId) tb加个别名 http://topic.csdn.net/u/20101208/10/7da17e9a-6ef6-49a4-93f2-5f7482fe961d.html 看看这个帖 select count(*) from (select CNId from WorkFlow group by CNId)t sql 语句执行问题 如何提取数据库里的字段名和说明 太无聊了,问一个问题,如果把两个表无条件的放在一个表里面! SELECT查询问题 行列转换后排序问题 在 sqlserver 中使用 opendatasource() 从 dbf 文件中读取数据时,date 字段的数据发生错误 如何获得SQl SERVER2000中某一数据库字符集? 如何实现两个数据库的数据同步?? 一个关于触发器得sql,请高手赐教 VFP中,查询时有多条记录满足条件,设置按扭让满足条件的记录逐条显示,怎样按扭代码? SQL 统计汇总--如何提高统计时间 100分求 SQL2005不用循环行转列,列转行问题
select startTime from WorkFlow where CNId= ?
数据量小用游标吧
select startTime from WorkFlow where CNId=要么就游标
因为你少了个子查询充当表的别名。加上红色部分就可以了。
在数据库中编写代码如下:
declare @sql varchar(5000)
begin
set @sql='select mycolumn as ''中文'' from mytable'
exec(@sql)
end
列名显示??
怎样才能正常显示中文列名(必须是拼写sql的形式)
这样写就对了!
加个别名
看看这个帖