我的数据库是mysql的。忘了说明。 :)
解决方案 »
- mysql记录超300W条,修改表结构超时,有什么好办法。
- 订单流水号=年月日+插入时记录的ID,如何实现?
- 重置MYSQL数据库密码以后APPSERV不能启动了
- MySQL 不想设立主键可以吗
- 向:ACMAIN_CHM 提问
- Linux英文版中mysql储存显示中文!请教!!
- 两个数据库表的写入(急)!
- 如何设置mysql字符集(在linux上,mysql4.1.13)
- 我想将一个数据库含表的结构和数据全部copy后,重命名,应怎么做?
- 非常感谢beyound兄弟帮助我解决了一大难题,特此散分
- WIN2000下面,MYSQL的控制台看不到在DOS下新建的数据库?
- 请问ems mysql manager如何使用啊 ,有教程下吗?
create temporary table tmp select distinct * from test where to_days(date_col)>=to_days('2004-03-01') and to_days(date_col)<=to_days('2004-07-01');
select * from tmp;
select user_col,sum(mount) as mount from tmp group by user_col order by mount desc;
drop table tmp;
执行上面的语句如下:mysql> select * from test;
+----------+------------+-------+
| user_col | date_col | mount |
+----------+------------+-------+
| a | 2004-03-01 | 5 |
| b | 2004-05-03 | 6 |
| a | 2004-03-01 | 5 |
| c | 2004-06-03 | 6 |
| b | 2004-05-03 | 6 |
| b | 2004-05-03 | 6 |
| c | 2004-05-06 | 3 |
+----------+------------+-------+
7 rows in set (0.00 sec)mysql> create temporary table tmp select distinct * from test where to_days(date
_col)>=to_days('2004-03-01') and to_days(date_col)<=to_days('2004-07-01');
Query OK, 4 rows affected (0.06 sec)
Records: 4 Duplicates: 0 Warnings: 0mysql> select * from tmp;
+----------+------------+-------+
| user_col | date_col | mount |
+----------+------------+-------+
| a | 2004-03-01 | 5 |
| b | 2004-05-03 | 6 |
| c | 2004-06-03 | 6 |
| c | 2004-05-06 | 3 |
+----------+------------+-------+
4 rows in set (0.00 sec)mysql> select user_col,sum(mount) as mount from tmp group by user_col order by m
ount desc;
+----------+-------+
| user_col | mount |
+----------+-------+
| c | 9 |
| b | 6 |
| a | 5 |
+----------+-------+
3 rows in set (0.00 sec)mysql> drop table tmp;
Query OK, 0 rows affected (0.00 sec)
I searched for the information about the "temporary table" which says the temporary table will auto-dispear when your process ends. I have test this just though IE and it looks well, now I wonder need I insert the "drop" action at the end of my program. ( the tools JSP,Tomcat, OS is Linux)
thanks