I have a table where users could vote on a subject, but the script allowed people to vote more than once when only one vote per person is allowed. I can determine who is who on the 'colleague' column
i.e.
colleague vote1 vote2 vote3
1 a b c
2 c b a
1 b c a
As you can see, colleague a voted twice, I only want to take their most recent vote.
If I use select distinct colleague, vote1, vote2, vote3 from table it is picking all as they are actuially different.
What I need is to only select distinct on the colleague column but my query needs to output all rows.
Does that make sense? Can I structure a SQL query that will do what I want?
i.e.
colleague vote1 vote2 vote3
1 a b c
2 c b a
1 b c a
As you can see, colleague a voted twice, I only want to take their most recent vote.
If I use select distinct colleague, vote1, vote2, vote3 from table it is picking all as they are actuially different.
What I need is to only select distinct on the colleague column but my query needs to output all rows.
Does that make sense? Can I structure a SQL query that will do what I want?