Oracle Query for finding non-repeated rows

岁酱吖の 提交于 2020-01-06 07:54:35

问题


I will try to put forward this question in a simple way. Consider that I have a table with two columns (Name, Contact_No). We can have the same name but with different Contact No in the table. All I want to know is to find out which name is NOT repeated in the entire table. Or in other words, which name is unique in this table and has appeared only once.. This is just an example, the actual scenario is quite different but if anyone can help me with this example, I'll be able to handle the actual scenario.

Here is an example

Name     Contact_No

A        123
A        124
B        125
C        126
C        127

All I want is to find (B) which is not repeated in the entire table. Thanks


回答1:


You can simply do this:

SELECT name FROM tbl_name GROUP BY name HAVING COUNT(name) = 1 

Check Out SQLFIDDLE



来源:https://stackoverflow.com/questions/12365678/oracle-query-for-finding-non-repeated-rows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!