I am writing this query to find duplicate CTN Records in table1. So my thinking is if the CTN_NO appears more than twice or higher , I want it shown in my SELECT * statement output on top.
I tried the following sub-query logic but I need pulls
SELECT *
table1
WHERE S_IND='Y'
and CTN_NO = (select CTN_NO
from table1
where S_IND='Y'
and count(CTN_NO) < 2);
order by 2