Howdy folks.
I'm working with an Oracle 8i database. I know just about enough SQL to get myself into trouble, and now I'm stuck. I'm looking for a way to select certain data, and I think it may be possible using CASE, but I can't quite figure it out.
The table I'm selecting from is simple. It has just a person ID and a status ID. One person can have more than one status.
I'm trying to select the values from the table, but with the following "rules":
- if there is just one record for the person_id, return the status_id
- if there are multiple records for one person_id, return the value "multiple" (and return the person_id just once)
So, for example, let's say the table looks like this:
I would like the query to return the following:
Any ideas?
Thanks,
Steve
I'm working with an Oracle 8i database. I know just about enough SQL to get myself into trouble, and now I'm stuck. I'm looking for a way to select certain data, and I think it may be possible using CASE, but I can't quite figure it out.
The table I'm selecting from is simple. It has just a person ID and a status ID. One person can have more than one status.
I'm trying to select the values from the table, but with the following "rules":
- if there is just one record for the person_id, return the status_id
- if there are multiple records for one person_id, return the value "multiple" (and return the person_id just once)
So, for example, let's say the table looks like this:
Code:
Person_ID Status_ID
12345 1
55555 1
55555 2
55555 3
I would like the query to return the following:
Code:
Person_ID Status_ID
12345 1
55555 multiple
Thanks,
Steve