[散分]出个题散个分~~~

fishmans 2006-04-18 11:25:33
题目很简单~

有一个表table1
结构与数据如下:
a b
01 2006-02-02
01 2006-02-02
02 2006-02-02
03 2006-02-01
03 2006-02-06
03 2006-02-02
04 2006-02-02
04 2006-02-02
05 2006-02-09
05 2006-02-12

'======================
要求如下:
以最简短的SQL求出有多个日期的a
如上结构结果为:
03
05

'===========================
分给最先给出结果并且SQL最简短的同志~~~~~~~~~~
OK,GO~~~

...全文
193 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
yedl830128 2006-04-21
  • 打赏
  • 举报
回复
小弟出言不知天高地厚,大哥能谅解还能给分。实在感激,以后我定多加努力,不让大哥们失望!
fishmans 2006-04-20
  • 打赏
  • 举报
回复
结帐了~~
看到yedl830128这么执着也给个20吧~
jabeginner 2006-04-19
  • 打赏
  • 举报
回复
Select B.a From (Select A.a, Count(*) As Counts From (select distinct * from Table1) A Group By A.a) B Where B.Counts > 1
yedl830128 2006-04-19
  • 打赏
  • 举报
回复
select max(c)
from (select count(b) as c from table1 group by (a));
这会应该行了.
yedl830128 2006-04-19
  • 打赏
  • 举报
回复
如果在 oracle 中 能否试试
select c from (select distinct(b) as c from table1 group by a)
where rownum<2
faysky2 2006-04-19
  • 打赏
  • 举报
回复
select distinct A.a from table1 A where A.b<>(select top 1 b from table1 B where A.a=B.a)
faysky2 2006-04-19
  • 打赏
  • 举报
回复

create table tb1(a char(2),b datetime)
insert into tb1 select '01', '2006-02-02'
union all select '01','2006-02-02'
union all select '02','2006-02-02'
union all select '03','2006-02-01'
union all select '03','2006-02-06'
union all select '03','2006-02-02'
union all select '04','2006-02-02'
union all select '04','2006-02-02'
union all select '05','2006-02-09'
union all select '05','2006-02-12'

select distinct a1.a from tb1 a1 where a1.b<>(select top 1 b from tb1 a2 where a1.a=a2.a)

drop table tb1
bulletCoderHope 2006-04-19
  • 打赏
  • 举报
回复
我都没读明白他的题目
求出有多个日期的a
又没主键
junki 2006-04-19
  • 打赏
  • 举报
回复
进来学习一下.
GoldFox 2006-04-19
  • 打赏
  • 举报
回复
Select B.a From (Select A.a, Count(*) As Counts From (select distinct * from Table1) A Group By A.a) B Where B.Counts > 1
of123 2006-04-19
  • 打赏
  • 举报
回复
select distinct a from (select a, b from table 1 group by a, b) where count(a) > 1
of123 2006-04-19
  • 打赏
  • 举报
回复
select a from (select a, b from table 1 group by a, b) where count(a) > 1
yedl830128 2006-04-19
  • 打赏
  • 举报
回复
谢谢指教.
fishmans 2006-04-19
  • 打赏
  • 举报
回复
嗯,这里只有northwolves(狼行天下) 是最好的,不过应该可以不加distinct的

另:那个自称可以拿一百分的同志,那个having是否要放group by 后面??而且就是加个主键对要求和结果也没什么影响并且也用不到。
TERRYYRRET 2006-04-19
  • 打赏
  • 举报
回复
接分
yedl830128 2006-04-19
  • 打赏
  • 举报
回复
我试了俩小时,认为大哥的表结构不满足关系表数据的行唯一性要求.
想问大哥认为 01 到底有几个日期?
yedl830128 2006-04-19
  • 打赏
  • 举报
回复
select a,count(b)
from table1
having(count(b))>1
group by a
order by count(b) desc;
小弟自认为能拿到这100 分了.
空心兜兜 2006-04-19
  • 打赏
  • 举报
回复
偶来接分咯!
yedl830128 2006-04-19
  • 打赏
  • 举报
回复
希望小弟这次能帮得上你的忙
select a,count(b)
from table1
group by a
having count(b)=(select max(count(b))
from table 1
group by a);
northwolves 2006-04-19
  • 打赏
  • 举报
回复
try:

select distinct a from table1 group by a having max(b)>min(b)
加载更多回复(3)

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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