关于一条SQL语句

来源:百度知道 编辑:UC知道 时间:2024/06/23 16:30:12
oracle数据库 表名testTable 字段 testTitle ,testDate(日期:年-月-日)
请问:查询该表中 某一日期段的,testTitel中重复的值,重复的值都显示出来,即,只有一条的(没重复值),的不显示。
如查询该表中 从2005年1月5日到2006年2月7日的,有重复的记录,没重复的不显示,重复的全部显示。

综合 1楼和3楼的改成这样:

select *from testTable as T1
where
testDate between 2005-1-5 and 2006-2-7
and T1.testTitle in
(select count(testTitle) from testTable as group by testTitel having count(testTitle)>=2 )

select testDate,testTitel,count(*)
from testTable
group by testDate,testTitel
having count(*)>=2

上面的答案貌似不对吧!count是计数,这count记的是元组的数量,和题目貌似没关系啊!
select testData,testTitel
from testTable as t1 inner join testTable as t2 on t1.testData=t2.testData and t1.testTitel=t2.testTitel

select *from testTable as T1
where
testDate between 2005-1-5 and 2006-2-7
and
(select count(1)from testTable as T2 where T2.testTitle =T1.testTitle )>1

select testTitel from testTable
where testDate between 2005-1-5 and 2006-2-7
group by testTitel
having count(1)>1