Kreation
Kreation

Reputation: 327

Display only top result from mysql query?

How can I display only the top/largest percentage from this query?

select round((count(*)*100)/(select count(*) from test),1) as percent from test group by field1 order by percent desc

For example this is data received from the query:

enter image description here

What I want displayed on an HTML page from this query is this:

enter image description here

Upvotes: 1

Views: 476

Answers (1)

Bheem Raj
Bheem Raj

Reputation: 173

MySQL Limit!

select round((count(*)*100)/(select count(*) from test),1) as percent from test group by field1 order by percent desc LIMIT 1;

Upvotes: 2

Related Questions