Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C_Doc_Code c_Product_Code n_priority
D94334 BR00004 1
D94335 BR00012 1
D94335 BR00049 2
D94335 BR00047 3
D94335 BR00047 3
D94336 I00001 4
D94336 BR00054 5
D94336 BR00052 2
D94336 BR00052 2
D94337 BR00001 1
D94337 BR00001 1


Please obsereve the table deeply some doctor codes in column first having product codes 2 times in second column..pls tell how to extract only those doctor codes along with product code..
Posted
Updated 6-Feb-15 18:05pm
v2

1 solution

Try this:
SQL
select distinct c_doc_code, c_product_code from table1 t1 where
(
  select count(*) from table1 t2 where t2.c_product_code=t1.c_product_code
) > 1
 
Share this answer
 
Comments
Member 11337367 7-Feb-15 0:59am    
It is onlly one table how can i make table 1 and table 2
Peter Leow 7-Feb-15 1:06am    
What do you mean? Are you asking a new question? This SQL query is quering the same table which I named it table 1 in this example. You should change it to your table name. Try it and you will get the output your want.
If you need some tutorials on sql, visit: http://www.w3schools.com/sql/sql_select.asp
Member 11337367 7-Feb-15 1:11am    
No thanks..
Peter Leow 7-Feb-15 1:33am    
I just noticed that you have re-posted this question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900