Re: first LIMIT then ORDER

2004-04-24 Thread Jigal van Hemert
From: "Anders Karlsson" <[EMAIL PROTECTED]> > And by the way, in a UNION, there is no need to put parenteses around > the unioned queries in the general case. So > (SELECT .) UNION (SELECT) [ORDER BY ] > Is the same as > SELECT . UNION SELECT [ORDER BY ] > I say in the gene

Re: first LIMIT then ORDER

2004-04-24 Thread Anders Karlsson
As I stated before, my guess that duplicates are removed is because the SELECT is handled like one part of a UNION (I'll have a look at the code later to check if this is the case). Really, a UNION should consist of two or more SELECTs, so this is not the expected behaviour. The way this REALLY

Re: first LIMIT then ORDER

2004-04-24 Thread Jigal van Hemert
> I find by experiment that > (select * from FOO order by a desc limit 10) order by a; > removes duplicates, but, if I drop the second order clause, > (select * from FOO order by a desc limit 10); > duplicates are retained. > > Why is the first a union, but not the second? Just curious. On ht

Re: first LIMIT then ORDER

2004-04-24 Thread Bill Easton
curious. > From: "Keith C. Ivey" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Date: Fri, 23 Apr 2004 11:27:38 -0400 > Subject: Re: first LIMIT then ORDER > On 23 Apr 2004 at 7:23, Bill Easton wrote: > > The last suggestion is useful when you do care wh

Re: first LIMIT then ORDER

2004-04-23 Thread Keith C. Ivey
On 23 Apr 2004 at 7:23, Bill Easton wrote: > The last suggestion is useful when you do care which entries you get, > as you can use one order for limit and another for presentation. For > example, if you'd like the LAST 10 rows, but sorted in FORWARD order, > you can use something like > > (s

Re: first LIMIT then ORDER

2004-04-23 Thread Bill Easton
it 10) order by version; And I thought I'd have to wait for subqueries... Date: Thu, 22 Apr 2004 10:35:17 -0500 To: "Keith C. Ivey" <[EMAIL PROTECTED]>, [EMAIL PROTECTED] From: Paul DuBois <[EMAIL PROTECTED]> Subject: Re: first LIMIT then ORDER At 11:21 -0400 4/22/04, Keit

Re: first LIMIT then ORDER

2004-04-22 Thread Paul DuBois
At 11:21 -0400 4/22/04, Keith C. Ivey wrote: On 22 Apr 2004 at 12:31, Johan Hook wrote: Assuming you want to order your arbitrary selection you could do something like: (SELECT t.Id FROM tab t LIMIT 10) UNION ALL (SELECT t.Id FROM tab t WHERE 1 < 0) ORDER BY t.Id You don't even need to inclu

Re: first LIMIT then ORDER

2004-04-22 Thread Keith C. Ivey
On 22 Apr 2004 at 12:31, Johan Hook wrote: > Assuming you want to order your arbitrary selection you could > do something like: > (SELECT t.Id FROM tab t LIMIT 10) > UNION ALL > (SELECT t.Id FROM tab t WHERE 1 < 0) > ORDER BY t.Id You don't even need to include the dummy query. You can do a UNIO

Re: first LIMIT then ORDER

2004-04-22 Thread Paul DuBois
At 11:35 +0200 4/22/04, Harald Fuchs wrote: In article <[EMAIL PROTECTED]>, Paul DuBois <[EMAIL PROTECTED]> writes: At 18:51 +0200 4/21/04, Jacek Jaroczynski wrote: Is there possibility to first LIMIT and then ORDER records? Not with a single SELECT. ORDER BY occurs before LIMIT. You could u

Re: first LIMIT then ORDER

2004-04-22 Thread Johan Hook
Assuming you want to order your arbitrary selection you could do something like: (SELECT t.Id FROM tab t LIMIT 10) UNION ALL (SELECT t.Id FROM tab t WHERE 1 < 0) ORDER BY t.Id /Johan Harald Fuchs wrote: In article <[EMAIL PROTECTED]>, Paul DuBois <[EMAIL PROTECTED]> writes: At 18:51 +0200 4/21/0

Re: first LIMIT then ORDER

2004-04-21 Thread Paul DuBois
At 18:51 +0200 4/21/04, Jacek Jaroczynski wrote: Is there possibility to first LIMIT and then ORDER records? Not with a single SELECT. ORDER BY occurs before LIMIT. You could use LIMIT and select into a temporary table, then select from the temporary table with ORDER BY. Using simple query I can