userid createDate
------ ----------
AAAA 2009-06-01
AAAA 2009-06-01
BBBB 2009-06-01
BBBB 2009-06-02
BBBB 2009-06-02
CCCC 2009-06-02
AAAA 2009-06-03
BBBB 2009-06-03
CCCC 2009-06-03
DDDD 2009-06-03如何查询每天新增的用户得到结果createDate newUserCount
---------- -----------
2009-06-01 2
2009-06-02 2
2009-06-03 1
------ ----------
AAAA 2009-06-01
AAAA 2009-06-01
BBBB 2009-06-01
BBBB 2009-06-02
BBBB 2009-06-02
CCCC 2009-06-02
AAAA 2009-06-03
BBBB 2009-06-03
CCCC 2009-06-03
DDDD 2009-06-03如何查询每天新增的用户得到结果createDate newUserCount
---------- -----------
2009-06-01 2
2009-06-02 2
2009-06-03 1
解决方案 »
- 请教 如何导出或者删除 服务器上的ssis实例
- asp查询问题
- 江湖救急,明明有记录,为什么查不出来?
- 月份间隔
- 还是没有解决,生成树的问题,哪位高手出手帮忙啊!!!
- 求助!一个datediff的问题!
- 这句sql 语句有错吗? sql="select top 1 xinxi.title,gongsi.gsmc from xinxi inner join gongsi on xinxin.gs_id=gongsi.id ...
- 如何去除字段中的空格?
- VB6+SQL SERVER2000在XP下编译好的程序在98下为什么不能连接数据库?
- sql语句在access里的问题 ,来抢分把
- 高人留步,一个查询问题,谢谢
- sql 字符比较
createDate newUserCount
---------- -----------
2009-06-01 2
2009-06-02 1
2009-06-03 1
group by createDate
order by createDate
convert(varchar(10),createDate,120) as createDate,
count(distinct userid) as newUserCount
from
tb
group by
convert(varchar(10),createDate,120)
select aa.createDate,newUserCount=count(distinct aa.userid) from
(select * from tb a where not exists(select 1 from tb where userid=a.userid and createDate<a.createDate)) aa
group by aa.createDate
order by aa.createDate