Finding duplicate values in a SQL table and group by creation date [closed] - sql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
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?

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

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

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

Related

SQL command to find the repetitive day? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 months ago.
Improve this question
on which day most people login?
Use DAYNAME() like that.
SELECT DAYNAME([column_with_date])
FROM [table]
GROUP BY DAYNAME([column_with_date])
order by count(DAYNAME([column_with_date])) desc limit 1;
You can use below code to find max frequency
select date,max(freq)
from (SELECT date,count(date) as freq from TableName
group by date);
this will give the Date and max frequency of that date in column.
or you can use below code
SELECT date,count(date) as freq from TableName
group by date
limit 1;
here i'm assuming date as column name.

Select the most recent date from the table [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a purchase order table that has a list of order numbers and associated order lines with different dates. I want to a query to fetch the orders with orderlines that has the most recent date.
I want the fetch to result in something like below
Here is a way to do this using row_number
select * from (
select t.*
,row_number() over(partition by ordernumber,orderlinenumber order by date desc) as rnk
from <your_table> t
)x
where x.rnk=1

How can we display the last 7 Records from table in Oracle 11G SQL only? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
How can I write this query without TOP and Limit only use the SQL
You just sort the data one way, grab the records you want, then sort it the other way:
SELECT SOME_FIELD
FROM (SELECT st.*
FROM SOME_TABLE st
ORDER BY SOME_FIELD DESC)
WHERE ROWNUM <= 7
ORDER BY SOME_FIELD ASC
dbfiddle here

To select max date and time [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have data with column createdate like '24/04/2019 14:52:38',24/04/2019 14:52:37,24/04/2019 14:52:35,24/03/2019 14:52:38 etc.
how to get data based on max date and time in SQL query.
select
top(1) *
from
xx
order by
createdate desc
something like this? (works if createdate column is of date/datetime/timestamp type)
select
*
from
<table_name>
where
createdate = (select
max(createdate)
from
<table_name>)

Oracle - put sequence order in column salary where salary is null [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
How can I put 1,2,3,4.... in sequence order in column salary where salary is null?? in oracle
I tried many things but could not find any accurate result
select nvl(column,1) as columnName from yourTable
Use ROWNUM pseudocolumn with nvl function:
select nvl(salary, ROWNUM ) from yourTable
ROWNUM pseudocolumn returns a number indicating the order in which Oracle selects the row from a table or set of joined rows. The first row selected has a ROWNUM of 1, the second has 2, and so on.