I have a table defined as this:
CREATE TABLE A_TEST (
"ID" NUMBER NOT NULL ENABLE,
"TYPE" VARCHAR2(20 BYTE),
)
- ID is not a primary key.
- TYPE might be NULL
- An ID I can have 0, 1 or more TYPEs.
if I want to get IDs with differents types I will write this query:
SELECT distinct a1.ID FROM A_TEST a1
JOIN A_TEST a2 on a2.ID = a1.ID and a2.type != a1.type
But how can I find Ids for which I have a single type defined?
(only one row for Id or many rows for id with only one having a type defined)
After the clarifications, it seems that your requirements are: