Re: Top N selections + rest row

2006-04-25 Thread Joerg Bruehe
Hi Cor, all! C.R.Vegelin wrote: Hi Joerg, All, I would like to have something like: Country Type20042005 -- GermanySales13357 19843 Belgium Sales12224 16767 France Sales15443 16602 Un. States Sales

Re: Top N selections + rest row

2006-04-25 Thread C.R.Vegelin
]> To: "Shawn Green" <[EMAIL PROTECTED]>; "C.R.Vegelin" <[EMAIL PROTECTED]> Cc: Sent: Tuesday, April 25, 2006 2:17 PM Subject: Re: Top N selections + rest row Hi Shawn, Cor, all! Shawn Green wrote: --- "C.R.Vegelin" <[EMAIL PROTECTED]> wro

Re: Top N selections + rest row

2006-04-25 Thread C.R.Vegelin
in" <[EMAIL PROTECTED]>; "Martijn Tonies" <[EMAIL PROTECTED]>; ; <[EMAIL PROTECTED]> Sent: Tuesday, April 25, 2006 1:18 PM Subject: Re: Top N selections + rest row --- "C.R.Vegelin" <[EMAIL PROTECTED]> wrote: Thanks Martijn, Barry, I was wonder

Re: Top N selections + rest row

2006-04-25 Thread Joerg Bruehe
Hi Shawn, Cor, all! Shawn Green wrote: --- "C.R.Vegelin" <[EMAIL PROTECTED]> wrote: 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

Re: Top N selections + rest row

2006-04-25 Thread Martijn Tonies
> > 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.

Re: Top N selections + rest row

2006-04-25 Thread Shawn Green
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 > > - Original Message - > From: "Martijn Tonies" <[EMAIL PROTECTE

Re: Top N selections + rest row

2006-04-25 Thread C.R.Vegelin
countries + Rest in a pie graph. So I need one additional row in the Top-N query. Regards, Cor - Original Message - From: "Martijn Tonies" <[EMAIL PROTECTED]> To: Sent: Tuesday, April 25, 2006 11:06 AM Subject: Re: Top N selections + rest row Hi, Anybody with smart id

Re: Top N selections + rest row

2006-04-25 Thread Martijn Tonies
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

Re: Top N selections + rest row

2006-04-25 Thread Barry
C.R.Vegelin wrote: Hi All, 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,

RE: top one row

2005-08-05 Thread Gordon Bruce
This is out of the MySQL class and is called the Max-Concat trick. What is the biggest country in each continent? "The Rows Holding the Group-wise Maximum of a Certain Field" MySQL> Select Continent, -> SUBSTRING(M

Re: top one row

2005-08-05 Thread Scott Noyes
mysql> SELECT VERSION(); +---+ | VERSION() | +---+ | 4.1.7-nt | +---+ 1 row in set (0.00 sec) mysql> CREATE TABLE test (col1 INT, col2 INT, col3 INT); Query OK, 0 rows affected (0.08 sec) mysql> INSERT INTO test VALUES (1, 1, 1), (1, 2, 3); Query OK, 2 rows affected (0.02

RE: top one row

2005-08-05 Thread Jay Blanchard
[snip] > SELECT col1, MAX(col2), col3 FROM table GROUP BY col1; Because col3 is not part of the GROUP BY clause, this query will not guarantee that the col3 returned is associated with the col2 returned. In other words, running this query on the table containing col1 / col2 / col3 1 1

Re: top one row

2005-08-05 Thread Scott Noyes
> SELECT col1, MAX(col2), col3 FROM table GROUP BY col1; Because col3 is not part of the GROUP BY clause, this query will not guarantee that the col3 returned is associated with the col2 returned. In other words, running this query on the table containing col1 / col2 / col3 1 11 1

RE: top one row

2005-08-05 Thread Jay Blanchard
[snip] The same way you do it inother SQL's. SELECT MAX(col2) FROM table GROUP BY col1; [/snip] Oops; SELECT col1, MAX(col2), col3 FROM table GROUP BY col1; -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

RE: top one row

2005-08-05 Thread Jay Blanchard
[snip] I have a simple table col1 col2col3 A 2 3 A 100 70 A 100080 B20 90 B7080 To select the top one row for each unique value of col1 select distinct on (col1), col1, col2, col3 from table order by col1, col2 desc, col3 desc;

Re: top one row

2005-08-05 Thread Scott Noyes
You're looking for the rows containing the group-wise maximum. There's an explanation in the manual, section 3.6.4, http://dev.mysql.com/doc/mysql/en/example-maximum-column-group-row.html On 8/5/05, Kemin Zhou <[EMAIL PROTECTED]> wrote: > I have a simple table > > col1 col2col3 > A 2

Re: TOP N record

2005-05-13 Thread Mike Wexler
SELECT date1, process, wip, worm FROM table WHERE field=value ORDER BY otherField DESC LIMIT N Seena Blace wrote: Hi, how to get top N records from table ? columns of table id date1 process wip worm I need output date1 process wip worm 5/5/05

RE: TOP

2004-07-29 Thread SGreen
> iv_alert.sourceIPAddr, iv_alert.sourcePort, iv_alert.networkProtocolId ") > PRINTF(s_Columns, "%s%s%s", s_Columns0, s_Columns1, s_Columns2) > BREAKPOINT() > /* > - DO NOT CHANGE THE LINES BELOW - > */ > LOOKUP("SelectDB_CheckStatus","eSecur

RE: TOP

2004-07-29 Thread Kamal Ahmed
--- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 28, 2004 2:44 PM To: Kamal Ahmed Cc: [EMAIL PROTECTED] Subject: Re: TOP

Re: TOP

2004-07-28 Thread Justin Swanhart
TOP is a microsoft SQL extension. MySQL uses the LIMIT clause. for instance, the following is a rather typical "top 10" sql query: select some_column, sum(another_column) total from some_table group by some_column order by total desc LIMIT 10 On Wed, 28 Jul 2004 14:39:11 -0400, Kamal Ahmed <

Re: TOP

2004-07-28 Thread SGreen
In MS SQL Server (T-SQL) you say SELECT TOP n In MySQL you use: SELECT LIMIT n (http://dev.mysql.com/doc/mysql/en/SELECT.html) There is no direct equivalent to SELECT TOP n PERCENT Yours, Shawn Green Database Administrator Unimin Corporation - Spruce Pine "Kamal Ahmed" <[EMA