数据库的统计问题

danmali 2003-12-23 02:01:58
现在有4个数据表a,b,c,d,表中都含有 tel 字段!要统计4个表中tel字段所有重复的值,并列出来,sql语言怎么写?(我想知道用什么方法能先把4个表中的tel字段的数据先汇总起来,是用视图吗?)请老鸟们帮帮忙!
...全文
85 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
LoveSQL 2003-12-23
  • 打赏
  • 举报
回复
select tel
from
( select tel from a
union all
select tel from b
union all
select tel from c
union all
select tel from d
) a
group by tel
having count(*)>1
victorycyz 2003-12-23
  • 打赏
  • 举报
回复
不好意思,雷同了。我回贴的时候只看到了一楼的回贴的。
victorycyz 2003-12-23
  • 打赏
  • 举报
回复
用楼上的方法:
select tel
from
( select tel from a
union all
select tel from b
union all
select tel from c
union all
select tel from d
) a
group by tel
having count(*)>1

gmlxf 2003-12-23
  • 打赏
  • 举报
回复
具有重复的tel:

select tel from
(select tel from a
union all
select tel from b
union all
select tel from c
union all
select tel from d
) a group by tel having count(*)>1
gmlxf 2003-12-23
  • 打赏
  • 举报
回复
汇总union all:

select tel from a
union all
select tel from b
union all
select tel from c
union all
select tel from d

34,576

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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