On Apr 10, 2010, at 10:02 PM, Ashley M. Kirchner wrote:
>
>
> Given a MySQL query like this $q = "select num from table", I get a result
> like this:
>
>
>
> +---+
>
> |num|
>
> +---+
>
> | 1|
>
> | 4|
>
> | 6|
>
> | 2|
>
> | 4|
>
> | 5|
>
> | 3|
>
> | 2|
>
> | 4|
>
> |
If you want to take top 5:
SELECT num, COUNT( num ) as c FROM table GROUP BY num order by c desc limit
5
Thanks,
Vikash Kumar
--
http://vika.sh
On Sun, Apr 11, 2010 at 8:07 AM, Dan Joseph wrote:
> Eh, he's off topic, but we've talked plenty SQL on here before...
>
> SELECT num, COUNT( num ) F
Eh, he's off topic, but we've talked plenty SQL on here before...
SELECT num, COUNT( num ) FROM table GROUP BY num;
I don't have a myqsl server to test that, but should do it.
--
-Dan Joseph
www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month. Promo
Code "NEWTHINGS" for 10% off
Ashley M. Kirchner wrote:
Given a MySQL query like this $q = "select num from table", I get a result
like this:
+---+
|num|
+---+
| 1|
| 4|
| 6|
| 2|
| 4|
| 5|
| 3|
| 2|
| 4|
| 2|
| 3|
| 3|
| 2|
| 1|
+---+
What I want is a listing of numbers sorted by the amoun
4 matches
Mail list logo