要统计一个表中某字段不重复的条数该怎么搞? 比如说要统计表abc中a字段不重复的条数:先创建一个视图1select distinct a form abcselect count(a) as a之count from 视图1上面过程用一条SQL能解决吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select count(a) as a之count from (select distinct a form abc) as T Select count(distinct a) as cn form abc --用子查询-楼主,你的from写成form了!select count(a) as a之count from (select distinct a from abc) as T select [a之count]=count(distinct a) form abc--这样就行了 select [a之count]=count(distinct a) from abc--这里的form 表单改为from select count(distinct a) as [a之count] from abc select count(distinct a)form abc 多谢各位回复,还有个问题,用这样可以select [a之count]=count(distinct a) from abc但我在存储过程中把它赋值给一个变量就不行,显示:在关键字 'FROM' 附近有语法错误。这是为什么?set @a=count(distinct a) from abc select @a=count(distinct a) from abc declare @a intselect @a=count(distinct a) from abc--或set @a=(select count(distinct a) from abc) SQL查询效率问题? 动态SQL变量赋值的问题 HELP!这个SQL怎么写? 求组表合并! sqlserver2000服务器恢复的问题 请教数据库增长的奇怪现象 sql查询问题,急!! 超级SQL难题(问题方案探讨) 数据以数组形式保存的,如何按要求修改数组内容.. 菜鸟的问题 只知道一个值,不知道是哪个字段和哪张表的,请问该如何查询? 数据分析问题。
select count(a) as a之count
from (select distinct a form abc) as T
-楼主,你的from写成form了!select count(a) as a之count
from (select distinct a from abc) as T
select [a之count]=count(distinct a) from abc
但我在存储过程中把它赋值给一个变量就不行,显示:在关键字 'FROM' 附近有语法错误。这是为什么?
set @a=count(distinct a) from abc