10 messages in com.mysql.lists.mysqlRe: Top N selections + rest row
FromSent OnAttachments
C.R.Vegelin25 Apr 2006 02:55 
Barry25 Apr 2006 03:00 
Martijn Tonies25 Apr 2006 03:06 
C.R.Vegelin25 Apr 2006 05:13 
Shawn Green25 Apr 2006 05:17 
Martijn Tonies25 Apr 2006 05:33 
Joerg Bruehe25 Apr 2006 06:17 
C.R.Vegelin25 Apr 2006 06:32 
C.R.Vegelin25 Apr 2006 06:53 
Joerg Bruehe25 Apr 2006 08:25 
Subject:Re: Top N selections + rest row
From:C.R.Vegelin (cr.v@hetnet.nl)
Date:04/25/2006 05:13:27 AM
List:com.mysql.lists.mysql

Thanks Martijn, Barry, I was wondering whether it could be done in a single query. I want users to decide how many countries they want, and show world sales on top of report followed by the N countries. This to enable relative country shares, both for reporting and graphs. For example, Top-10 countries + Rest in a pie graph. So I need one additional row in the Top-N query. Regards, Cor

Hi,

Anybody with smart ideas to get Top-N rows plus the rest row ? Suppose I have ranked sales values descending for 2005, like: Select Country, Sum(Sales) AS Sales From myTable Where Year=2005 Group By Country Order By Sales DESC LIMIT 25;

Then I get Top-25 sales rows, but I also want a rest row, where all 26 rows represent the world total. I'm using MySQL 5.0.15.

What about just removing the LIMIT clause?

Or, alternatively, do a skip of the first 25 rows? (check the docs for that)

Do you want to get this in a single result, or additional result?