Hi Friends,
I have a table like
name
MAD
LHR
MAD
LHR
AKL
AWL
AKL
LHR
I want the output as:
LHR 3
AKL 2
AWL 1
etc...
ie the no of entires sorted by their no of appearences.
I cannot do that by select name from tab_name group by name as it will not
give me the no of rows.
Pl. help me to find
Hi Abishek,
I want the output as:
LHR 3
AKL 2
AWL 1
This should do it:
SELECT name, COUNT(*) as num
FROM tab_name
GROUP BY name
ORDER BY num DESC
Regards,
Jeremy
--
Jeremy Cole
MySQL Geek, Yahoo! Inc.
Desk: 408 349 5104
--
MySQL General Mailing List
For list archives:
Abhishek
I want the output as:
LHR 3
AKL 2
AWL 1...
ie the no of entires sorted by their no of appearences.
SELECT
tbl.name AS Name,
COUNT( tbl.name) AS Count
FROM tbl
GROUP BY tbl.name
ORDER BY Count DESC;
PB
[EMAIL PROTECTED] wrote:
Hi Friends,
I have a table like
name
MAD
LHR
MAD
This query should tell you how many occurrences of each value you have in
the table:
select name, count(*) as count
from mytable
group by name
order by count desc
Rhino
- Original Message -
From: [EMAIL PROTECTED]
To: mysql@lists.mysql.com
Sent: Tuesday, November 22, 2005 11:25 AM