SQL - fetch records based on a condition of two columns -


i need fetch records order no = abc has more 1 tracking number in large table can that?

i'll assume you're fetching records orders , "large table" trackingnumbers. can group by orderno in sub-query , refine sub-query using having clause. sub-query return ordernos in table more once. example:

select orderno   orders  orderno in (select orderno                      trackingnumbers                     group orderno                    having count(*) > 1) 

to identify duplicates in single table (as mentioned in comments):

select *   orders  group trackingnumber having count(*) > 1 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -