如何多次选择具有相同值的列 [英] how to select the column which having same value multiple times

查看:68
本文介绍了如何多次选择具有相同值的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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





请深入了解表中的一些医生代码,在第二列中首先提供产品代码2次。请告诉我们如何仅提取那些医生代码以及产品代码..

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..

推荐答案

试试这个:

Try this:
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


这篇关于如何多次选择具有相同值的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆