SQL CE DISTINCT AGGREGATE

旧城冷巷雨未停 提交于 2020-01-11 12:04:13

问题


Does SQL CE has the ability to use distinct in aggregate functions? I need something like

SELECT count(distinct date) FROM table

This is simplified query and I already have GROUP BY used in original one.


回答1:


SQL Server CE (current version) does not support count(distinct)

The workaround is a GROUP BY, which sounds like what you are using

select count(*) from (
    select distinct date from tbl
) x

Or if other fields are involved

select groupcol, count(*)
from (
    select groupcol, date
    from tbl
    group by groupcol, date
) x
group by groupcol


来源:https://stackoverflow.com/questions/5064592/sql-ce-distinct-aggregate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!