List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:November 22 2005 4:41pm
Subject:Re: Getting no of different rows by group by clause
View as plain text  
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


mail@stripped wrote:

>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 it. I know it would be simple but i think i am missing
>some basic of MySQL.
>Thanks
>--
>Regards
>Abhishek Jain
>
>--------------------------------------------------------------------
>mail2web - Check your email from the web at
>http://mail2web.com/ .
>
>
>
>  
>


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.5/177 - Release Date: 11/21/2005

Thread
Getting no of different rows by group by clausemail@ejain.com22 Nov
  • Re: Getting no of different rows by group by clauseJeremy Cole22 Nov
  • Re: Getting no of different rows by group by clausePeter Brawley22 Nov
  • Re: Getting no of different rows by group by clauseRhino22 Nov