简体   繁体   中英

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

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

SELECT * FROM accounts ORDER BY month DESC

may work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM