How to get distinct rows (descending order) based on a column

Hi Team,

I have a table like this
id Bid status
1 1 init
2 2 active
3 1 expired
4 1 active
5 3 init

Now I would like to get all distinct rows on BId in descending order of id, so my result shoud be like

2 2 active
4 1 active
5 3 init

Is there any way to get this directly with the query?
I am using MySQL.

2 Likes

Doing as you suggested only returns BId, but i need all the three columns. If i do select * it returns duplicate BId.

Use the groupBy method.