SQL命令高手速进!~~~

来源:百度知道 编辑:UC知道 时间:2024/06/04 13:47:38
ID 时间
1 2008-10-10
2 2008-10-10
3 2008-10-20
4 2008-10-30
5 2008-10-30

查询结果:认为5条记录中只有3天有记录,要求一行SQL语句搞定。
gzz_gzz说的SQL命令不对,执行后显示为:
时间
2008-10-10 2
2008-10-20 1
2008-10-30 2
我要的是执行后就一行记录集,直接就等于3

select count(*) from (select 时间 from 表 group by 时间) as 时间表

SELECT COUNT(*) FROM (SELECT 时间 from 表名 group by 时间) AS A

就是这样了 错不了!

select count(*) from (select 时间 from tablename group by 时间)a

这样就行了

select count(*) from(select 时间 from 表名 group by 时间);
结果等于3

select distinct 时间 from 表

select time from table1
where record IS NOT NULL
group by time