List:General Discussion« Previous MessageNext Message »
From:C.R.Vegelin Date:February 22 2008 12:49pm
Subject:Re: SELECT ascending incremental values
View as plain text  
Hi Waynn,

Try:
SET @row := 0;
SELECT @row := @row + 1 AS Rank,
    UserId, count(*) as NumActions from Actions group
    by UserId order by NumActions desc limit 10;

HTH, Cor

----- Original Message ----- 
From: "Waynn Lue" <waynnlue@stripped>
To: <mysql@stripped>
Sent: Friday, February 22, 2008 10:38 AM
Subject: SELECT ascending incremental values


> I'm doing a top 10 list from a database based on a group by and order
> by, something like
>
> select UserId, count(*) as NumActions from Actions group
> by UserId order by NumActions desc limit 10;
>
> Is there any way to put a separate column so I get results like
> Rank, UserId, NumActions
> 1, 123, 43
> 2, 9844, 40
> 3, 88, 34
> 4, 144240, 20
> etc.?
>
> Waynn
>
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>
> 


Thread
SELECT ascending incremental valuesWaynn Lue22 Feb
  • Re: SELECT ascending incremental valuesC.R.Vegelin22 Feb
    • Re: SELECT ascending incremental valuesWaynn Lue25 Feb