Har
Har

Reputation: 5004

Merge two rows in SQL for-fitting one column field

I have 2 Rows on a Table

Device_ID    Other_ID
========     ========
633          1
232          2
242          2

I need the following results:

Device_ID    Other_ID
========     ========
633          1
232          2     

How can this be done in SQL?

Thanks!

Upvotes: 0

Views: 110

Answers (1)

Erwin Brandstetter
Erwin Brandstetter

Reputation: 656471

SELECT min(Device_ID) AS Device_ID, Other_ID
FROM   tbl
GROUP  BY Other_ID
ORDER  BY Other_ID;

Upvotes: 3

Related Questions