I’m very new to SQL so I appologize if this question is difficult to understand.
Let’s say I have a table like:
Name Birthday Bob 7/18 Bob 7/18 Mark 5/10 Mark 7/5 Sue 2/1 Joe 1/14 Joe 1/14 Joe 1/2 Jeff 9/16 Jeff 3/20 Jeff 6/13 [...]
I would like to perform a select statement that gives me the Names of the people who have more than one distinct Birthdays.
So, for my example table, the output would be Mark, Joe, and Jeff.
Thanks for your help.
A re-wording as I understand your problem statement:
All Names where:
– The name has more than one Colour associated to it
– Of those, at least two Colours have different birthday’s associated to them
What I’m unsure of is whether it’s possible to have two different birthdays for the same colour associated to the same name?
If
no, the colour becomes irrelevant, you just want a name with more than 1 different birthday associated to it.If `yes`, you need to find another record with the same name, but also a different colour AND a different birthday.
SELECT
Name
FROM
yourTable
WHERE
EXISTS (SELECT * FROM yourTable as [lookup] WHERE Name = yourTable.Name AND Birthday yourTable.Birthday AND Colour yourTable.Colour)
GROUP BY
Name