简体   繁体   中英

getting top exchange rate using sql

can someone show me how to get top exchange rate cause I'm really struggling to do it for example I have a table of 20 records and has 2 money that is of USD currency 3 money that is of Euro currency 4 money that is of Peso currency 5 money that is of Japanese yen currency then get the top 5 of it when I query the table the result would be something like this

Top exchange rate:

   Currency         Count
   ------------    --------
   Japanese Yen       5
   Peso               4
   Euro               3
   USD                2

thanks in advance

Try this:

SELECT currency
      ,COUNT(*) rate
FROM rates
GROUP BY currency
ORDER BY rate DESC
LIMIT 5;

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