http://topic.csdn.net/u/20071221/15/88c1036a-7c55-4ea2-94b8-c739c0c616f3.html大家帮忙看看上面的帖子谢谢
解决方案 »
- 请问如何利用mysql对实验记录数据进行管理
- 如何建立mysql可视化平台
- 基于mysql数据库进行数据挖掘可行么?
- 刚安装了个5.0版的mysql数据库,怎么就连接不上呢???
- 请教一下误删除了frm文件后,,如何恢复数据?
- 关于mysql里面如何进行自动编号?
- 莫名其妙的Memory fault???
- mysql 单表数据30万列表页显示很慢,难道是服务器mysql配置问题?还是我的sql查询语句问题,还是MYSQL对几十万的数据处理本身就慢
- MYSQL如何将ID相同的几行数据求和并显示在最后一列上?
- mysql 报错 [Err] 1055
- 取得自增主键值的并发性问题
- 這個超級難的MySQL語句該如何寫呢?
Query OK, 0 rows affected (0.00 sec)mysql> insert into test1 values (1,'2007/12/21 12:00'), (2,'2007/12/21 01:00'),(3,'2007/12/21 03:00');
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0mysql> create temporary table test_hour
-> (id int not null);
Query OK, 0 rows affected (0.01 sec)mysql> insert into test_hour values
-> (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20),(21),(22),(23),(0);
Query OK, 24 rows affected (0.00 sec)
Records: 24 Duplicates: 0 Warnings: 0mysql> create temporary table tmp select id, f_date,hour(f_date) h from test1;
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0mysql> select count(b.id) cnt, sum(case when b.h is null then 0 else 1 end) h from test_hour a left join tmp b on a.id = b.h group by a.id;
+-----+------+
| cnt | h |
+-----+------+
| 0 | 0 |
| 1 | 1 |
| 0 | 0 |
| 1 | 1 |
| 0 | 0 |
| 0 | 0 |
| 0 | 0 |
| 0 | 0 |
| 0 | 0 |
| 0 | 0 |
| 0 | 0 |
| 0 | 0 |
| 1 | 1 |
| 0 | 0 |
| 0 | 0 |
| 0 | 0 |
| 0 | 0 |
| 0 | 0 |
| 0 | 0 |
| 0 | 0 |
| 0 | 0 |
| 0 | 0 |
| 0 | 0 |
| 0 | 0 |
+-----+------+
24 rows in set (0.00 sec)