I have this table where 3 columns could have same information where the last 4 columns can sometime be the same and other times can have different values.
In below sample that you will also have in the attachment, you see that Brampton John Carson have 3 records but when you look at the columns Result1 to Result4, 2 rows are the same versus the other is different.
As for Ajax Bruce Saxton, Result1 to Result4 have the same values on both rows.
The objective for me is to only extract from the table when i have the same value from City, Name and Family name and when i have more then 1 difference in columns Reult1 to Result4.
Example. If my table got:
The query result would return:
How can i do that?
SELECT city, name, family_name, result1, result2, result3, result4 FROM (SELECT t.*, COUNT(DISTINCT result4) OVER (PARTITION BY city, name, family_name) cnt, ROW_NUMBER() OVER(PARTITION BY city,name,family_name,result4 ORDER BY ROWNUM) rn FROM yourtable t) WHERE cnt != 1 AND rn = 1
That's for your help. this is exactly what i was looking for.
Oracle Database
Oracle is an object-relational database management system. It supports a large number of languages and application development frameworks. Its primary languages are SQL, PL/SQL and Java, but it also includes support for C and C++. Oracle also has its own enterprise modules and application server software.
Open in new window