如何显示重复记录 ( 积分: 50 )

  • 主题发起人 主题发起人 zqssoft
  • 开始时间 开始时间
Z

zqssoft

Unregistered / Unconfirmed
GUEST, unregistred user!
在一个Acess数据库中,有下列记录,数据字段名为 year,例:
2005
2003
2004
2005
2006
2007
2008
2004
...
如何在AdoTable或用SQL查询语句实现,在DBGrid中显示这个字段所有重复的项目,如:
2004...
2004...
2005...
2005...
谢谢。
 
...group by ..having ..
SELECT year, Count(*) AS [count]
FROM table
GROUP BY year
HAVING count(*)>1;
 
select year from table1 group by year having count(*)>1
 
select year from (select year,count(*) as tmp from table1 group by year) a where a.tmp>1
 
group by having count(*)>1的使用;
 
angellover你怎么改成跟我一样的解答?上次来看你并没解出来啊
 
这个答案还是不对,呵呵..我还是没想到,所以只是加了个重复的个数...这个只是列出了重复的,并没有列出重复的所有内容
 
select * from table where year in (select year from table1 group by year having count(*)>1)
 
group by name having count(name) > 2
 
学习SQL语句,一定要重点学习SELECT的嵌套,一条很的SQL语句看起来很复杂,但你把嵌套看清楚 了,其实非常简单。
 
列出重复的,接下来就简单了,用in或用right join就可以了
 
学习了..楼上说的都不错..缺乏灵活应用了
select * from table where year in (select year from table group by year having count(*)>1) order by year;
 
后退
顶部