Code Break
Code Break

Reputation: 33

How to Show Top Value filed as top in Mysql

I want to show the college name and num of applications comes to each college and show most application received college as first position in MySQL query?

This is sample table, clg is college name and application_name column must be count() and highest value field must be show on top

enter image description here

My results must be like this....

enter image description here

Upvotes: 0

Views: 95

Answers (2)

Gordon Linoff
Gordon Linoff

Reputation: 1270493

I am answering this because the columns in a select should be unique, particularly when they are referenced in the order by clause. The query should look more like:

SELECT s.clg, count(*) as cnt 
FROM sample s 
GROUP BY s.clg
ORDER BY cnt DESC ;

Upvotes: 0

Dhaval Naphade
Dhaval Naphade

Reputation: 579

try this,

SELECT `clg`,count(`clg`) AS clg 
FROM demo 
GROUP BY `clg` 
ORDER BY clg DESC 

Upvotes: 3

Related Questions