hi folks ,
I have a Table names A with these fields (Id,Entry_Date,State)
I want to fetch the 5 recent records with Unique States And Order them Desc
so this is what I did
Select * From A Order By Entry_Date Desc Limit 5
I tried many ways to do this , first of All I tried to work with Distinct but I figured out that Distinct is applied to a Row not a field
Select Distinct State,Id From A Order By Entry_Date Desc Limit 5
it gives me the same result.
so I tried to solve the problem by group by
Select Distinct State,Id From A group by State Order By Entry_Date Desc Limit 5
but As you know the group by has to be before order and its giving me some other results
so I am wondering how can I do this !!!
Please help me on this