SQL Query to find people who have interviews in different rooms inany days

Viewed 57
Name Date Room
Jerry 2-2-21 D
Sam 2-2-21 A
Sarah 2-2-21 A
Will 3-2-21 B
Sam 4-3-21 D
Will 2-2-21 B
Jerry 2-2-21 D

Hello, (apologies for my bad English) I made the previous table I'm a new at SQL and wondering to how can I make a query that will return the names of the people who had interviews in different rooms regardless of the day so will would not come up since he had interviews in the same rooms

my approach

SELECT name
FROM worktable
DISTINCT room > 2

I don't' know what else to do thank you any help appreciated

2 Answers

In addition to @Beso answer I would also use DISTINCT in COUNT to be sure there are different rooms.

SELECT name
FROM worktable
GROUP BY name
HAVING COUNT(DISTINCT name) > 1

In this case only Sam will be included in the select output.

Related