I have a table like this:
ID | CODE | VALUE |
---|---|---|
1 | A | 123 |
1 | A | 456 |
1 | C | 123 |
1 | B | 789 |
2 | A | 344 |
2 | B | 344 |
I would like to see all cases that for the same ID we have different values for different codes.
Result: ID 1, CODE B VALUE 789 NOT FOUND ID 1, CODE A VALUE 456 NOT FOUND
In summary I need to see all diferences the I didn't find on column VALUE based in the ID key BUT NOT FOR THE SAME "CODE" COLUMN.
Anyone know how to achive that?
Thanks a lot!
Provided no duplicate rows exist, ie (ID, CODE, VALUE) is unique you can find VALUEs associated with exactly one CODE each with
select ID, max(CODE) CODE, VALUE
from tbl
group by ID, VALUE
having count(*) = 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.