按创建日期在SQL表和组中查找重复值

时间:2021-10-22 12:54:31

What's the simplest SQL statement that will return the duplicate values for a given column for example ORDERS_NUMBERS and group it by oldest CREATION_DATE in an Oracle database table?

什么是最简单的SQL语句,它将返回给定列的重复值,例如ORDERS_NUMBERS,并在Oracle数据库表中按最旧的CREATION_DATE对其进行分组?

3 个解决方案

#1


1  

SELECT   ORDER_NUMBERS, count(*)
FROM     YourTableName
GROUP_BY ORDER_NUMBERS
HAVING   count(*) > 1
ORDER BY CREATION_DATE

#2


0  

select ORDERS_NUMBERS,CREATION_DATE,count(*)
from
table
group by ORDERS_NUMBERS,CREATION_DATE
order by CREATION_DATE desc 
having count(*) > 1

#3


0  

select 
t.orders_numbers, 
t.creation_date

from table t
group by t.orders_numbers, 
t.creation_date
having (count (*) >1)
;

#1


1  

SELECT   ORDER_NUMBERS, count(*)
FROM     YourTableName
GROUP_BY ORDER_NUMBERS
HAVING   count(*) > 1
ORDER BY CREATION_DATE

#2


0  

select ORDERS_NUMBERS,CREATION_DATE,count(*)
from
table
group by ORDERS_NUMBERS,CREATION_DATE
order by CREATION_DATE desc 
having count(*) > 1

#3


0  

select 
t.orders_numbers, 
t.creation_date

from table t
group by t.orders_numbers, 
t.creation_date
having (count (*) >1)
;