再出100分提问 http://topic.csdn.net/u/20071221/15/88c1036a-7c55-4ea2-94b8-c739c0c616f3.html大家帮忙看看上面的帖子谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 参考。mysql> create table test1 (id int not null,f_date datetime not null);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) 菜鸟求助,关于mysql trigger的一个问题 mysql的问题(急等) 这个查询郁闷我两天了.请教大家. create trigger出错的问题 #100 mysql中to_number用什么代替? 这样的sql语句怎样写呀???急急,在线等 ,高手帮帮忙把 请高手指教:请问在mysql中怎样使两个表有参照完整性约束呢? 关于MYSQL_CONNECT(),有点疑问 问大家一个关于mysql的问题??? 请问如何在mysql中增加和删除用户? 取得自增主键值的并发性问题 這個超級難的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)