Chinaunix
标题:
这样的数据如何单条SQL语句提取呢?
[打印本页]
作者:
Manson.H
时间:
2006-08-31 12:43
标题:
这样的数据如何单条SQL语句提取呢?
+---------+------------------------+---------+---------------------------+
| ID | FAddr | Bytes | TAddr |
+---------+------------------------+---------+---------------------------+
| 3863740 |
support@spdns.com
| 1554 |
023_fj@sina.com
|
| 3863739 |
liuyi_061@yahoo.com.cn
| 1273 |
zg@cczj.net
|
| 3863738 |
grant@gi-bracelet.org
| 4103 |
wxb@ahjdmy.com
|
| 3863737 |
hr@chinafloors.com
| 148393 |
sandy.lin@chinafloors.com
|
| 3863736 |
delin@wxchangfang.com
| 1486025 |
weiqing1003@yahoo.com.cn
|
| 3863735 |
lkjsaf@sunlush.com.cn
| 5459 |
hr@semperit.com.cn
|
+---------+------------------------+---------+---------------------------+
FAddr这个字段全是发送邮件的地址,Bytes是邮件字节数
我现在想把整个库里的几百万行邮件数据里发送邮件最多的10个域名 '@'后面的地址,提取出来,并且count出每个名总共发了多少信,总字节数是多少,单条语句如何写呢?往指点
作者:
ipaddr
时间:
2006-08-31 21:09
试试这个:
select SUBSTRING(FAddr,LOCATE('@',FAddr)),count(*),sum(Bytes) from tablename group by SUBSTRING(FAddr,LOCATE('@',FAddr))
作者:
okchina
时间:
2006-09-01 10:54
不知道FAddr 有没有索引,如果没有的话,会很慢的.
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2