I have the following table:

```
serialNumber  value masterID
1             red   500
1             blue  501
2             red   502
2             green 503
2             black 504

```

I need a single query that returns the following

```
serialNumber  value
1             blue 
2             black

```

I mean, I need the latest data that was inserted in the table for each serialNumber. MasterID is an incremental identity (PK).

I only managed to retrieve the last value for a single row (using top 1 and order by masterid desc) but I need to retrieve lot of data and making a query for each serialNumber is not viable.

Thanks!