请教一个SQL词句

arorn 2008-10-21 10:34:34
表:user
字段:email
email里面有很类型的邮箱.
怎么样写一个统计表里面各种邮箱的总数的SQL语句?
...全文
105 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
ruilab 2012-02-03
  • 打赏
  • 举报
回复
非常有用!
WoooXVi 2008-10-21
  • 打赏
  • 举报
回复


读取出来
再用ASP统计不行吗?

dim rs,aMCount(),iMType,aMList(),sMail,n,iHave
iMType=-1
set rs = Cn.execute("Select email From list")
do until rs.Eof
sMail = lcase(split(rs(0),"@")(ubound(split(rs(0),"@"))))
iHave = -1
for n = 0 to iMCount
if aMList(n) = sMail then
iHave = n
exit for
end if
next
if -1 = iHave then
iMType = iMType + 1
redim Preserve aMCount(iMType)
redim Preserve aMList(iMType)
aMCount(iMType) = 1
aMList(iMType) = sMail
else
aMCount(iHave) = aMCount(iHave) + 1
end if
rs.movenext
loop
set rs = nothing




不知道运行不运行得起来
最后:
aMCount() = 各种Mail的数量组成的数组
aMList() = 与aMCount对应,是各种Mail的@后面的字符
iMType+1 = Mail的种类数量
arorn 2008-10-21
  • 打赏
  • 举报
回复

select count(*)as EamilCount,email from [User] group by [email]
是用这个语句吗?

我没看出来跟普通的有什么区别,我运行一下,还是没有统计出来
luojingjing 2008-10-21
  • 打赏
  • 举报
回复
sCount  email
3     sally.luo@163.com
464    sally.luo@scottwilson.com.cn
2     sally.luo@sina.com

这是我执行出来的结果.就是根据不同邮箱来统计的.呵~~
arorn 2008-10-21
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 luojingjing 的回复:]
引用 11 楼 arorn 的回复:
引用 10 楼 luojingjing 的回复:
看看这个是不是符合你的要求:

select count(*)as EamilCount,email from [User] group by [email]

谢谢这个不行的.每个邮箱都是不同的.


每个邮箱都是不同的,什么意思?你不是要统计不同邮箱的总数吗?
[/Quote]
比如:
123@126.com
1234@QQ.com
13245@sina.com.cn
13245@yahoo.com.cn
....
我想统计126邮箱总共有多少个
qq邮箱有多少个
这样的统计
luojingjing 2008-10-21
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 arorn 的回复:]
引用 10 楼 luojingjing 的回复:
看看这个是不是符合你的要求:

select count(*)as EamilCount,email from [User] group by [email]

谢谢这个不行的.每个邮箱都是不同的.
[/Quote]

每个邮箱都是不同的,什么意思?你不是要统计不同邮箱的总数吗?
arorn 2008-10-21
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 luojingjing 的回复:]
看看这个是不是符合你的要求:

select count(*)as EamilCount,email from [User] group by [email]
[/Quote]
谢谢这个不行的.每个邮箱都是不同的.
luojingjing 2008-10-21
  • 打赏
  • 举报
回复
看看这个是不是符合你的要求:

select count(*)as EamilCount,email from [User] group by [email]
arorn 2008-10-21
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 sy_binbin 的回复:]
单独用SQL语句比较麻烦

dim a = "@126.com"
sql = "select count(id) from ta where instr(email,"&a&")>0" 'ACCESS数据库
sql = "select count(id) from ta where CHARINDEX("&a&",email)>0" 'SQL数据库
[/Quote]

不知道能不能用一条语句,group by 一下全部出来.这样写的话写麻烦了
arorn 2008-10-21
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 jwen_tang 的回复:]
不是很明白你的意思,但我猜,你的意思是不是说要统计,字段里面各邮箱地址后缀相同的邮箱地址总数,比如,有多少个是63.com的邮箱,有多少是hotmail.com的邮箱,有多少是126.com的邮箱,等等,是不是这个意思啦
[/Quote]就是这个意思
【如鱼饮水】 2008-10-21
  • 打赏
  • 举报
回复
那可能要用 like 了
sy_binbin 2008-10-21
  • 打赏
  • 举报
回复
单独用SQL语句比较麻烦

dim a = "@126.com"
sql = "select count(id) from ta where instr(email,"&a&")>0" 'ACCESS数据库
sql = "select count(id) from ta where CHARINDEX("&a&",email)>0" 'SQL数据库
jwen_tang 2008-10-21
  • 打赏
  • 举报
回复
晕。。。更新慢了点,发错了。。。
jwen_tang 2008-10-21
  • 打赏
  • 举报
回复
不是很明白你的意思,但我猜,你的意思是不是说要统计,字段里面各邮箱地址后缀相同的邮箱地址总数,比如,有多少个是63.com的邮箱,有多少是hotmail.com的邮箱,有多少是126.com的邮箱,等等,是不是这个意思啦
arorn 2008-10-21
  • 打赏
  • 举报
回复
比如说:12@126.com
12@qq.com
12@sina.com.cn
我想统计出126邮箱有多少个
QQ邮箱有多少个
arorn 2008-10-21
  • 打赏
  • 举报
回复
比如说:12@126.com
12@qq.com
12@sina.com.cn
我想统计出126邮箱有多少个
QQ邮箱有多少个
Atai-Lu 2008-10-21
  • 打赏
  • 举报
回复
select count(*) as emailcount from [user]

emailcount就是数据总数
arorn 2008-10-21
  • 打赏
  • 举报
回复
[Quote=引用 18 楼 skywdq 的回复:]
如果注册的用户数达到一定程度,我们可以在数据库查询语句对其进行统计。

以下SQL语句能够统计出带某种类型后缀的email邮件注册量最大,及其排行顺序。

SELECT suffix_email, COUNT(suffix_email) AS email_count
FROM (SELECT SUBSTRING(email, CHARINDEX('@', email), 100) AS suffix_email
FROM user_table) temp_table
GROUP BY suffix_email
HAVING (COUNT(suffix_email) > 5)
ORDER BY email_c…
[/Quote]

就是这个..多谢
skywdq 2008-10-21
  • 打赏
  • 举报
回复
如果注册的用户数达到一定程度,我们可以在数据库查询语句对其进行统计。

以下SQL语句能够统计出带某种类型后缀的email邮件注册量最大,及其排行顺序。

SELECT suffix_email, COUNT(suffix_email) AS email_count
FROM (SELECT SUBSTRING(email, CHARINDEX('@', email), 100) AS suffix_email
FROM user_table) temp_table
GROUP BY suffix_email
HAVING (COUNT(suffix_email) > 5)
ORDER BY email_count DESC
某网站对此排名后,发现排名前15的邮箱如下:
@163.com
@126.com
@sina.com
@yahoo.com.cn
@sohu.com
@hotmail.com
@tom.com
@21cn.com
@263.com
@vip.sina.com
@yahoo.com
@163.net
@qq.com
@gmail.com
@eyou.com
skywdq 2008-10-21
  • 打赏
  • 举报
回复
如果注册的用户数达到一定程度,我们可以在数据库查询语句对其进行统计。

以下SQL语句能够统计出带某种类型后缀的email邮件注册量最大,及其排行顺序。

SELECT suffix_email, COUNT(suffix_email) AS email_count
FROM (SELECT SUBSTRING(email, CHARINDEX('@', email), 100) AS suffix_email
FROM user_table) temp_table
GROUP BY suffix_email
HAVING (COUNT(suffix_email) > 5)
ORDER BY email_count DESC
某网站对此排名后,发现排名前15的邮箱如下:
@163.com
@126.com
@sina.com
@yahoo.com.cn
@sohu.com
@hotmail.com
@tom.com
@21cn.com
@263.com
@vip.sina.com
@yahoo.com
@163.net
@qq.com
@gmail.com
@eyou.com

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧