Gayan
Gayan

Reputation: 2935

MySQL: Query to get all rows from highest month

I have a table named "accounts" and it has two fields "month" and "amount". I like to get highest month records to display front page

eg:

month amount

10/2013 -> 12
12/2013 -> 20
12/2013 -> 21
11/2013 -> 10

how could i filter highest month all data , I used time stamp format to store date

Upvotes: 1

Views: 63

Answers (2)

Jeevan Mysore
Jeevan Mysore

Reputation: 255

SELECT * FROM accounts ORDER BY month DESC

may work.

Upvotes: 0

Palec
Palec

Reputation: 13551

SELECT * FROM accounts WHERE month = (SELECT MAX(month) FROM accounts)

Upvotes: 2

Related Questions