楼主已经自己把问题解决了, 我来再补充一下 count 是能和distinct合用 的. 具体使用方式是 select hzxm, count( distinct xm) from gyjm where hbh='6252' and hkbbh='609000343' group by hzxm; 上面的 count( distinct xm) 意思就是, 如果在
想针对个别字段取消重复行的话,可以对该字段使用group by语句,例如:select c_id, min(s_id) from xskc group by c_id distinct 是确保整行数据不重复的,就像其他朋友已经说明的.
不用,直接 select count(distinct 列或表达式) from 表或select 字段1, count(distinct 字段2) from 表 group by 字段1
distinct 去重后再进行count 求条数,结果当然是1了,因为distinct -1.2表示去除表中所有重复的为-1.2的数据,而count ()是进行条数统计,所以最后无论是那个数,结果都会是1
我看了一段时间,没看懂意思,不过我认为可以通过嵌套一个SELECT(将空值过滤掉就行 WHERE TaskPlan_state<>null ).在外层SELECT中分组使用聚集函数就可以了.
select count(distinct(字段)) from 表;
select count(T.A) from (select distinct(有重复的字段名) as A from 表名 )T
我没有sql server数据库,无法测试你可以试试下面的写法:select sum(t3.fieldname) from (select top 3 fieldname from tablename) t3应该可以的.
个人建议这样用比理合理select count(distinct (aa)) +max(CASE WHEN aa IS NULL THEN 1 ELSE 0 END)from table1
select distinct 去重字段1,去重字段2 from 数据表 where 条件字段1 and 条件字段2