oracle - SQL find rows not having duplicate column values -


I have a query

  select * from circuit where y = 'b';  

I get the following results

  x | Location_A | Place_b Y ----------------------------------------- 1232 | Mexico | USA B1232 | Mexico | USA B1232 | Brasil | USA B 99 99 Brasil | USA B  

I need to know the x , which has no duplicated location_ and location_b. In this case the following data is printed.

1232 | Brasil | USA B 99 99 Brasil | USA B

I am using Oracle 10G Please let me know if this is possible. (Separate / group will remove duplicate, but still a line I do not need)

You can use the Analytical Function to calculate matches and then filter:

  select x, location_a, location_b, y (select c. *, Count (* ) Over (x, location_a, location_b) circuit as cnt) c where cnt = 1;  

Edit:

More section introduces an analytical function to actually understand them, you can see the documentation (see) Can start with. This special function specifies a value for each row in the result set. The value is the number of rows where the question of x , location_a , and location_b are the same value as the row for your data, it will be assigned:

  x | Location_A | Place_b Y CNT ----------------------------------------------- 1232 | Mexico | USA B 2 1232 | Mexico | USA B 2 1232 | Brasil | USA B 99 99 Brasil | USA B 1  

The first two lines have "2" because 1232 / Mexico / USA have two rows in one of the last two because they have three separate ones.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -