I have the following table

```
personid talent
1        swim
2        play
1        play
1        swim
2        play
3        swim
3        swim
2        play

```

So person 1 can both swim and play. Person 2 can only play. Person 3 can only swim.

I need to get the following result

```
personid  talent
1        both
2        play
3        swim

```

How can I do this using `exists` ?

---

I tried

```
SELECT DISTINCT personid, 
CASE WHEN (EXISTS(
SELECT * FROM mytable
 -- I got stuck

```

---

PS : I have a long solution that works . . But i do not like it because it is long 

```
SELECT DISTINCT dis2.personid , CASE WHEN talcount = 2 THEN 'both'
ELSE talent END AS talent 
FROM
(
SELECT personid , COUNT(talent) talcount
FROM 
(
SELECT DISTINCT personid , talent 
FROM my_table
) AS dis
GROUP BY personid
) dis2
JOIN my_table dis3
ON dis2.personid = dis3.personid

```