Reputation: 1190
Say I have a table like so:
ID Description
1 A popular place to eat!
1 A popular place to eat!!
1 A popular place to eat!!!
2 Lets go!
2 Everyone, Lets go!
And I just want one of the descriptions for each ID, since they are different in irrelevant ways:
ID Description
1 A popular place to eat!
2 Everyone, Lets go!
How can I write a SQL query to generate table 2 from table 1?
Upvotes: 2
Views: 3499
Reputation: 204784
Group by the column you want to be unique and use any aggregation function on the description
column like min()
or max()
select id, min(description)
from your_table
group by id
Upvotes: 4